Skip to content

fix(rpc): 修复特殊 Unicode 字符导致的会话读取和发送超时 - #553

Closed
zszz3 wants to merge 2 commits into
vastsa:mainfrom
zszz3:codex/fix-ndjson-unicode-548
Closed

zszz3 wants to merge 2 commits into
vastsa:mainfrom
zszz3:codex/fix-ndjson-unicode-548

Conversation

@zszz3

@zszz3 zszz3 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

问题与修复

Closes #548

会话内容含 U+2028 / U+2029 时,Node readline 会把一条合法 JSON 消息拆开,造成会话读取或发送请求超时。旧代码已用真实 host 进程复现:写入此类消息后,session.get 无法在测试期限内返回。

新增共用的 LF 分帧读取器,替换主进程读取 host stdout、主进程读取 sidecar stdout,以及 sidecar 读取 stdin 的三个入口。保留跨数据块的 UTF-8 字符、CRLF 和 EOF 尾帧兼容,并在关闭时释放缓冲和监听器。非法 JSON 仅记录字节长度,不记录消息内容。

文本内容、存储格式及协议版本不变;已有含特殊字符的会话可直接读取,无需修改用户数据。同步补充 RPC 规范和 E2E 场景。

验证

  • pnpm build:js、Desktop typecheck、pnpm lint、架构检查和 pnpm docs:check 通过。
  • Node 24 下全工作区测试通过:shared 734、agent-runtime 572、desktop 2063,其余包及文档测试均通过。
  • 新增 4 个读取器测试,覆盖所有 UTF-8 字节切分位置、连续消息、CRLF、EOF、关闭与监听器清理;读取器及既有 RPC 生命周期测试共 17 项通过。
  • pnpm test:e2e:rpc-unicode 通过:真实 HostProcess/AgentSidecar、隔离存储、本地模拟模型,覆盖历史读取与重启恢复、发送、host proxy 历史恢复、流式回复、收到回复后的 HostProcess 落库,以及错误回复后的健康检查。
  • 协议 smoke:22/22 通过,2 项真实模型测试因未配置凭证跳过。未进行桌面 UI 操作、Windows/Linux 原生验证;Rust 实现未修改,本地编译通过。

候选版本

  • Task candidate: b5aef762598a11f35db137a149eae6aa2b8de114
  • Base main: b07b64347693760a23d6e0374f3e263f25326481
  • Environment: macOS arm64 / Node 24.21.0;同一 Unicode E2E 另在 Electron 43.6.0 的 Node 模式下通过。
  • PR integration candidate: 527e127b3548e68c94c0179692ac5539bc4b7cd8
  • 已验证 GitHub 合并候选与本地测试提交的 tree 一致:806432619206a5754c224f6969ed928238a1d714

已补齐中文文档镜像的 E2E 索引行,最终提交本地文档检查和 Electron Unicode E2E 均通过。GitHub JS(构建 / 类型检查 / lint / 架构 / 全量测试)、Rust(格式 / clippy / 测试)和 Docs CI 均已通过。Vercel 预览需要维护者授权,此项尚未通过。

仓库交付文档仍有“先合入本地 main 再做 E2E”的旧描述;本次遵循根目录 AGENTS.md,在独立工作目录验证候选提交,未合入本地 main。

Read stdio frames at LF boundaries so valid Unicode text cannot split
requests or responses and strand their pending RPCs. Share the reader
across all three Node transport inputs and clean up on teardown.

Cover UTF-8 chunk boundaries and the real host/sidecar persistence and
prompt paths using isolated storage and a loopback provider.

fixes vastsa#548
Keep the translated specification structure and E2E traceability table aligned with the authoritative transport contract.
@vastsa

vastsa commented Sep 17, 2026

Copy link
Copy Markdown
Owner

已在当前 main 上落地:#557 (保留本 PR 的 LF 分帧修复,并补了 shared 单测 / 契约锁 / 中文文档)。合入后会关闭本 issue 与本 PR。

@vastsa

vastsa commented Sep 17, 2026

Copy link
Copy Markdown
Owner

已由 #557 合入(含本 PR 的分帧修复与落地加固)。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants