fix(mobile): cap TCP fallback listen with 5s timeout so reader can't silently hang#204
Open
codedogQBY wants to merge 1 commit into
Open
fix(mobile): cap TCP fallback listen with 5s timeout so reader can't silently hang#204codedogQBY wants to merge 1 commit into
codedogQBY wants to merge 1 commit into
Conversation
…silently hang
Symptom: on a dev client where neither @dr.pogodin/react-native-static-server
nor react-native-tcp-socket native modules are linked into the binary, the
reader spins forever on a sepia background with no error in Metro logs after
the Lighttpd 8s timeout warning.
Root cause: _startNativeServer caps Lighttpd.start() at 8s and falls through to
_startTcpFallback on timeout. But _startTcpFallback's server.listen() callback
never fires when the tcp-socket native binding is missing, and the promise sits
unresolved. ReaderScreen's await startFileServer() inherits the hang.
Fix: wrap server.listen()/server.on("error") in a settle helper with a 5s
timeout that closes the server and rejects with a clear actionable message
("rebuild with expo run:ios"). Lighttpd already had the same safety net.
This is a dev-environment guardrail — in a properly built binary both servers
return in well under 1s.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
已在这个 PR 里改了:移动端文件服务器 TCP fallback 的 listen 流程增加 5 秒超时保护,native 模块未正确链接时不会再让阅读器一直卡在 spinner,而是抛出可操作的错误提示。合并后会随下个版本修复。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
症状:当 dev client 二进制里两个文件服务器 native 模块(
@dr.pogodin/react-native-static-server的 Lighttpd 和react-native-tcp-socket)都没正确链接时,开书后阅读器一直卡在 spinner,Metro 日志在 Lighttpd 8s 超时警告之后完全没有任何后续输出。根因:
_startNativeServer已经给Lighttpd.start()加了 8s timeout,超时就 catch 并转_startTcpFallback_startTcpFallback里server.listen(callback)在 native binding 缺失时 callback 永不触发,promise 永久 hangawait startFileServer()继承这个 hang,错误从未 throw → 用户看到永久 spinner修复:把
server.listen()/server.on("error")用一个 settle helper 包起来,5s 超时关 server 并 reject 一个可操作的错误("rebuild with expo run:ios")。Lighttpd 已经有同样的保护,TCP 这条路径补齐对称。正常 build 的环境下两个服务器都在 1s 内返回,这个 timeout 仅在 dev 环境守底,不会误触发。
Test plan