Repository navigation
fix(factscribe): 握手超时时收掉引擎进程,不再每失败一次漏一个 - #205
Merged
MyPrototypeWhat merged 1 commit intoDec 4, 2026
Merged
Conversation
start() 里三条失败路径只有两条收尸:握手行读不懂、握手行里没端口,都调了 stop();握手超时直接抛出去,Python 子进程留在那儿。 留在那儿的是真正的孤儿:child 还指着它,但 port 还是 0,下一次拉起把 child 换成新的,漏掉的那个从此谁也收不到 —— 连 dispose() 也收不到,它只收当前句柄。 每失败一次漏一个。 现在握手超时也走 stop()(SIGTERM→SIGKILL)。createEngine 导出并接受 startTimeoutMs,测试用几百毫秒的阈值;默认仍是 20 秒,超时文案逐字不变。 新增 tests/engine-timeout-leak.test.mjs:用假解释器(探针问版本就打印 ≥3.10 的版本,拉起时只记 pid 然后一直挂着)走到握手超时,断言那个 pid 已经 不在了。未改代码上红(进程还活着),改完绿。 版本号 1.3.1。README 里「引擎进程何时被杀」补上失败这一次。
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.
引擎握手超时时,Python 子进程被留在那儿。
start()里三条失败路径只有两条收尸:握手行读不懂、握手行里没有端口,都调了stop();握手超时(20 秒内没等到就绪握手)直接抛出去,子进程留在那儿。留在那儿的是真正的孤儿。
child还指着它,但port还是 0,所以ensureReady()认为引擎没跑起来,5 秒冷却期一过就再拉起一个 —— 新的把child换成自己,漏掉的那个从此谁也收不到。dispose()只调engine.stop(),只杀当前句柄,同样收不到。每失败一次漏一个 Python 进程。改的是握手超时时也走
stop()(SIGTERM → 700ms 后 SIGKILL,与另外两条路径同一套)。createEngine导出,并接受一个可选的startTimeoutMs:默认仍是 20 秒,超时文案逐字不变,测试用几百毫秒的阈值不必等 20 秒。新增
tests/engine-timeout-leak.test.mjs:用假解释器(被版本探针问的时候打印一个 ≥3.10 的版本,被拉起的时候只记下自己的 pid 然后一直挂着)走到握手超时,断言那个 pid 已经不在了。未改的代码上红(进程还活着,报 Missing expected exception),改完绿。插件自带测试 33/33,仓库根npm run check0 error。版本号 1.3.1。
验证范围:只有 Node 22 上的测试是实测的。真实 Host 和 Electron 我没跑过 —— 这一层是仅个人判断。
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.