Repository navigation
test(worker): remote-runner 接管用例等 turn_input_committed 到达再断言,修 bun-test 高负载竞态 - #2611
Merged
Merged
Conversation
…st 高负载竞态 follow-up 在 recovered turn 终态后被 flush 提交时,turn_input_committed 由 runner status:busy 请求 resolve 后的微任务发出,而该 turn 的 turn_terminal 在 final 行落地时同步发出;provider 零延迟把 busy ACK 与 final 合并进同一 stdout chunk、且 runner 高负载(bun-test 串行 1824 文件) 时,receipt 经 worker IPC 到达父进程会晚于 terminal。原用例在「等到 terminal」后立即断言 committed,跨通道无顺序保证(与 #2597 引擎 attestation 用例同类),高负载下偶发 ExpectArrayContaining 失败。 生产侧提交确认确实有发(探针实证:同 chunk 下 committed 仅晚 terminal 6–393μs,5s 内必达),非生产缺陷。改为 waitFor 等 committed IPC 到达 再做快照断言;receipt 真缺失时 waitFor 10s 超时仍 fail,不掩盖回归。 变异复验(bun,CI 同引擎):在提交确认前注入 120ms 延迟,旧断言精确 复现 CI 的 ExpectArrayContaining 失败,新断言通过;无延迟双引擎 6/6 绿。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 30, 2026 13:03
|
@deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。 这次运行覆盖 3400614…0946357b3(9 个提交),同批合入的还有 #2542 #2600 #2578 #2590 #2612 #2594 #2548 #2615,失败不一定由本 PR 引起。
|
This was referenced Oct 30, 2026
|
🚀 Released in v3.56.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.
背景
bun-test在一次 PR 首跑中红了test/worker-remote-runner.integration.test.ts的「reattaches an active provider turn and emits its original terminal without replaying input」:expect(messages).toEqual(arrayContaining(...turn_input_committed for om_turn_followup...))失败,而同一轮里该 turn 的turn_execution_started / final_output / turn_terminal全部到达。该测试文件在多个相邻 commit 上 blob 逐字相同、邻近 CI run 通过,属时序竞态而非逻辑回归。根因(真实 spawn worker + provider 探针实证,非读代码推断)
follow-up 在 recovered turn 终态后被 flush 提交时:
turn_input_committed由 runnerstatus: busy请求 resolve 之后的微任务发出(src/worker.ts提交成功后的 deferred-commit 分支);turn_terminal在 providerfinal行落地时由 backend 同步回调发出。当 provider 零延迟把
status: busy与final合并进同一次 stdout 写入(同一 chunk)时,backend 在一次同步处理中先跑 final 回调(发 terminal),busy 的 resolve 微任务后跑(发 committed),于是 committed 经 worker IPC 到达父进程晚于 terminal。探针实测稳定晚 6–393μs。原用例在「轮询等到 terminal」后立刻断言 committed 已在数组里,等于假设两条通道(provider stdout 回调链 vs worker→父进程 IPC)有先后保证——它们没有。这与 #2597 修的引擎 attestation 用例是同一类「socket ack 与 worker IPC 不保证顺序」竞态。生产侧提交确认确实有发(committed 总是在数百微秒到毫秒内到达,从未丢失),真实 provider 的 busy ACK 与 final 之间隔着整轮执行时间,不会同 chunk,因此生产无此顺序,本 PR 只修测试。
改动
test/worker-remote-runner.integration.test.ts:在等到 follow-upturn_terminal之后、对消息数组做快照断言之前,加一个waitFor等该 turn(attempt 9、durablePrimaryInbox)的turn_input_committedIPC 到达。waitFor带 10s deadline,receipt 真缺失时仍会失败,不掩盖真实回归。与 #2597 的处理方式一致,纯测试改动,不碰 src。验证(Linux,bun 1.4.x)
bun test --timeout=180000 test/worker-remote-runner.integration.test.ts:6/6 通过(CI 的 bun-test 用 180s per-test 超时)。bun run test -- test/worker-remote-runner.integration.test.ts(vitest/node):6/6 通过。src/worker.ts提交确认前临时注入 120ms 延迟(模拟高负载下 receipt 晚到超过测试 50ms 轮询窗口)——ExpectArrayContaining {}失败;影响面:单个集成测试文件;不改生产代码、CLI、PTY/Tmux、持久化或通知。
本地复现注意
bun test默认 per-test 超时只有 5s,裸跑bun test <file>必然超时失败,与 CI 无关;CI 的 bun-test 由scripts/run-bun-tests.mjs以TEST_TIMEOUT_MS = 180_000运行。本地复现请用bun test --timeout=180000 test/worker-remote-runner.integration.test.ts。setup-bun@v2);本地用 1.4.4 验证结论同构(该竞态只涉及 worker IPC 与 microtask 排序,这两个版本无相关变更)。