Repository navigation
fix(terminal): Worker 退出后清理终端端口状态 - #975
Merged
deepcoldy merged 1 commit intoAug 23, 2026
Merged
Conversation
XiangYu-BD
force-pushed
the
fix/terminal-clear-stale-worker-port
branch
from
August 23, 2026 04:07
0975084 to
95f5c9e
Compare
Merged
deepcoldy
pushed a commit
that referenced
this pull request
Aug 23, 2026
落实 #974 合入评论的 4 条非阻断建议: 1. existingAppServer.endpoint 在 trim/URL 解析前显式拒绝 C0/DEL 控制字符(U+0000–U+001F、U+007F),不再依赖解析器静默剥离,所有调用方得到可打印、无歧义的 endpoint。 2. /detach、/disconnect 文字命令与 /close 使用同一套安全结果语义(missing/refused/residual/closed),仅在普通 closed 时确认断开,不再把未证实的清理报告为成功。 3. 收窄 existingAppServer 注释:不自动创建新 thread 仅适用于 cliId codex 的 shared-adopt 路径,codex-app 保留既有新会话工作流。 4. 文档明确 daemon 重启时 tmux 等持久后端与 pty 后端的不同 remote TUI 行为,并移除已属 #975 范畴的 Web 终端表述。 不改变 shared-adopt 主架构:不起第二个 App Server、不抢 writer、官方 codex --remote resume 作为第二客户端。 验证:3 个相关测试文件 299 项通过、tsc --noEmit 零输出、pnpm build 通过;针对当前 master(含 #855/#971)本地 trial merge 无冲突、合并树 tsc 与 299 测试复跑全绿。 Co-authored-by: Xiang Yu <[email protected]>
|
🚀 Released in v3.17.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.
概述
修复 worker 退出后 Web Terminal 仍可能被 Dashboard 代理到旧端口的问题。
这是通用的 worker 生命周期状态一致性修复,不依赖 Codex App、特定 IM 平台、终端静态资源加载或远程隧道实现。
根因
每个 worker 持有自己的终端 HTTP/WebSocket 监听端口。worker 正常退出、崩溃或重启时,运行态
ds.workerPort会被清空,但持久化session.webPort可能保留旧值,Dashboard 的聚合投影也没有收到端口失效通知。会出现以下状态不一致:
这不是浏览器问题:只要 active session 在 worker 退出后尚未由替代 worker 的
ready事件发布新端口,就可能发生。修复
在
worker.on('exit')的权威代次转换中:ds.workerPort;ds.session.webPort;Dashboard 不再把旧监听器当作有效终端目标。可重新 attach 的持久后端会在后续 wake/reattach 后通过新的
ready注册新端口;不可恢复会话则正确显示终端不可用,而不是代理到死 socket。范围
本 PR 不改:
它只修正终端可用性的运行态、持久化 session 行和 Dashboard 投影三者一致性。
验证
新增回归:模拟具有
workerPort/session.webPort的 worker 退出,断言:workerPort清除;session.webPort清除;session.update { webPort: null, workerPid: null }。已执行:
结果:5 个测试文件、90 项测试通过。
另已执行
pnpm build,通过 TypeScript、脚本类型检查、Dashboard 打包、公开域名审计和产物审计。