Repository navigation
fix(model-proxy): stdin EPIPE 不再抢在退出码前定性,缺失可执行文件稳定报 native_inference_failed - #2327
Merged
Merged
Conversation
…failed collectNativePrint 经 owner-guard sh 启动 CLI,该 shell 在本地进程运行期间一直持有 stdin, EPIPE 只会在它退出后出现;原实现收到 EPIPE 立即记 native_transport_closed, 和退出码 127 的先后取决于时序(CI 偶发)。改为退出后统一按退出码分类:非 0 → native_inference_failed, 0 退出但输入没送完 → native_transport_closed。 Closes #2325 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 25, 2026 08:28
This was referenced Oct 25, 2026
复审 P2:上一提交去掉了 EPIPE 时的 kill,当本地 CLI 退出但留下仍持有 stdout 的后代、调用方又没有 deadline(mcode exec 默认不限时长)时, close 永远不来、调用一直挂着。EPIPE 只会在 owner-guard sh 退出后出现,此时退出码已定,回收进程组只收掉残留后代,不影响按退出码定性。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
Author
|
已 squash 合入 master(193e6008b),落地树与评审树一致,master CI 已开跑。 评审中确认两处改前改后同形、master 本来就有的健壮性问题,本 PR 未引入也未覆盖,已另开 #2347 跟进,不影响本次合入:
|
deepcoldy
pushed a commit
that referenced
this pull request
Oct 25, 2026
deepcoldy
pushed a commit
that referenced
this pull request
Oct 25, 2026
This was referenced Oct 25, 2026
|
🚀 Released in v3.52.0 |
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.
Closes #2325
改了什么
collectNativePrint(services/constrained-invocation/print-process.ts)收到 stdin EPIPE 时,不再立即把失败记成native_transport_closed,只记下「输入没送完」并照旧回收进程组;等进程退出后再按退出码统一分类:native_inference_failed(例如可执行文件不存在,退出码 127);native_transport_closed,和原来一致;为什么
PR #2318 的 CI(test 3/3,job 121113171048)在
test/minimax-long-entry.test.ts「unavailable executable」这条上偶发失败:期望native_inference_failed,实际得到native_transport_closed。spawnOwnedModelProcess的 owner-guard sh 启动的。这个 shell 在本地进程运行期间一直持有 stdin,只有它退出后才会出现 EPIPE。可执行文件不存在时,shell 以 127 退出。我们写 stdin 的时机如果晚于它退出,EPIPE 就先到;原实现收到 EPIPE 立刻定性为native_transport_closed,退出码不再参与分类。两件事谁先谁后取决于时序,所以是偶发。native_inference_failed;输入 1MiB(超过管道缓冲)时,修复前必然得到native_transport_closed。model-proxy/server.ts)不受影响:它的已知错误码名单里没有这两个码,本来就统一回 502native_inference_failed。close要等全部 stdio 关闭才会触发;没有 kill 就会一直挂着。mcode exec 默认不限时长,没有调用方 deadline 兜底。现在 EPIPE 时照旧 SIGTERM(1 秒后 SIGKILL)整个进程组。EPIPE 只会在 owner-guard sh 退出后出现,那时退出码已经确定,回收进程组只会收掉残留的后代,不影响按退出码分类。影响面
print-process.ts一个函数。调用方是 mcode exec,以及 pi / gemini / opencode 的受限调用 runtime。native_process_exited或native_transport_closed,不受影响,本 PR 也没有改它们。native_transport_closed改成了native_inference_failed。这是修正错误分类,不是行为变化。HTTP 客户端看到的错误码不变,其余路径的返回值和错误码也都没变。验证
bun run build:通过。test/native-print-process.test.ts:全部用真实进程,都经函数自己启动、进程组由函数自己收尾,测试里不杀任何进程。覆盖四种情况:native_inference_failed;native_inference_failed;native_transport_closed;native-print-process/minimax-long-entry/constrained-invocation共 22 条,全过;bun test跑新文件 5 条,全过。合入后,#2318 同步 master 让 CI 跑在带修复的树上再合。
🤖 Generated with Claude Code