Repository navigation
fix(codex): app-server 探针的 stdin 写失败不再抛成进程级异常 - #2129
Merged
Merged
Conversation
CodexAppServerProbe(/resume 列表、原生标题读取与设置、归档)往 app-server 的 stdin 写请求时没有监听 stream error。app-server 停止读取(崩溃、关掉 stdin)后, 下一次写入异步报 EPIPE;没有监听时作为进程级异常抛出,而 daemon 没有 uncaughtException 兜底,整个 daemon 退出。同仓库的 codex-app-runner 早已监听。 改为与 codex-app-runner 一致:stdin 报错时以该错误结束所有挂起请求;各调用方 退出时照旧 close() 回收子进程。补确定性用例:fake app-server 在回 initialize 之前关掉 0 号 fd 并保持存活;修复前 vitest 报 Unhandled EPIPE、请求挂到超时, bun 同样失败。 Refs #2079 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 21, 2026 22:03
This was referenced Oct 21, 2026
Owner
Author
|
已合并 PR #2129 → 8652489(squash) 门禁:首审与 Pure(pi) 复审都在 head 9d4b077 上给出可合(0 P1 / 0 P2 / 0 P3)/ 必需 CI(build、test)与 bun-test、bun-binary*、Sandbox network boundary 共 15 项首跑全绿 / 老用户无 breakchange:只改「app-server 不再读 stdin」这条失败路径,正常路径不变 / 落地树与审过的合并树一致 follow-up(复审指出,范围外、既有代码):同一形状的「daemon 里子进程 stdin 未监听 error」还有两处—— 未做:发版、部署(需另行指令) |
This was referenced Oct 22, 2026
|
🚀 Released in v3.49.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.
改了什么
src/services/codex-app-threads.ts的CodexAppServerProbe给 app-server 子进程的stdin加上error监听:写入失败时,以Codex app-server stdin error: …结束所有挂起的请求。做法与同仓库的codex-app-runner一致(它早已有这条监听)。子进程照旧由各调用方在finally里close()回收(标题生成、线程列表、改名、读元数据、归档五处都有)。测试 fixture 新增
close-stdin-after-initialize行为:收到initialize后先关掉自己的 0 号 fd,再回响应并保持存活,于是 client 之后的每次写入都是 EPIPE。新增用例「rejects instead of crashing when the app-server stops reading its stdin」。为什么(根因:生产代码问题)
#2124 排查 codex-app-threads 偶发时发现的,与那条偶发本身无关,属于 #2079 的「子进程流写入 EPIPE」一类。
CodexAppServerProbe跑在 daemon 里(/resume线程列表、原生标题元数据读取)和 worker 里(原生标题生成与设置、归档)。app-server 一旦停止读取 stdin(崩溃、启动即退、关掉 stdin),probe 的下一次写入就会异步报 EPIPE;stdin上没有监听时,这个 stream error 被当作进程级异常抛出:src/index-daemon.ts顶部注释),整个 daemon 进程退出;用例怎么做到确定性复现
process.stdin.destroy()关闭 0–2 号 fd,所以 fixture 里显式closeSync(0),并且先关读端再回 initialize,client 收到响应时管道已经无人读取,不依赖时序。thread/name/set的请求体为 256KB,两种运行时都会走到 EPIPE。影响面
验证
Refs #2079
🤖 Generated with Claude Code