Repository navigation
test: fix flaky toolValueText and detached-abort unit tests - #687
Merged
Merged
Conversation
Rinat S (rsolmano)
requested review from
Olga Lavrichenko (OLavrik),
Rustam Sadykov (SBOne-Kenobi) and
danyaberezun
as code owners
October 8, 2026 13:30
🌐 Website previewPreview retired when this pull request closed. |
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.
Problem
The
Unit TestsCI job failed in 15 of 280 attempts between Sep 30 and Oct 8, and 11 of those came in the last two days, so PRs and merge-queue runs keep failing for reasons unrelated to their changes. Two flaky tests caused 9 of the 15 failures:toolValueText > falls back to String when JSON cannot serialize a value(extension-api, 6 failures; added Oct 6 in refactor(extensions): extract the host UI SDK and visualize web renderer #638). In Bun,JSON.stringify(cyclic, null, 2)takes time proportional to the stack size before it throws: about 300ms on macOS, about 650ms in Linux Docker, and 2.5–4.7s on CI even in passing runs, against the 5s test timeout. Without the indent argument it takes 0.4ms. There's no production impact:toolValueTextonly runs in the browser (V8).a detached run SURVIVES a parent-turn abort(pi-subagents, 3 failures). The test aborted the parent afterBun.sleep(30)and expected the abort to land inside a 150ms fake response, while the child finished at 250ms. When the runner is busy, the abort comes late and lands on the parent's follow-up turn (triggered by the child's completion), soPOST_ABORT_COMPLETIONnever appears and the test times out. I reproduced this locally by aborting at 244–254ms. If the abort is even later, the test passed without checking anything.The failure logs also showed misleading
git … failederrors inservertests. Those come from turbo stopping at the first failing package and killing the other test tasks mid-run (Tasks: 10 successful, 20 total).Approach
toolValueTextfallback covered, just without a cyclic object. Production code is untouched.--continueso one failing package doesn't hide the results of the others. Turbo still exits non-zero if any task fails.Deliberately out of scope (diagnosed, but the fix isn't proven yet):
serverterminal testclosing a tab removes it and reports closed(2 failures): on Ubuntu, interactivebashstarts child processes while reading its startup files, so an immediate close seesbusy. The proposed fix has not been run on Linux yet.pi-dagtestscomplete admitted topology remains readable beyond 64 KiB/cancel does not turn a human input gate…(4 failures): they fail because the CI runner is overloaded (about 200ms locally vs 0.7–6.8s on CI). This needs profiling rather than a longer timeout.Changes
packages/extension-api/src/toolResultContent.test.ts: the fallback test uses an object whosetoJSONthrows, plus a BigInt, instead of a cyclic object.packages/pi-subagents/src/extension.test.ts: the detached-run abort test is gated withdeferred()instead of sleeps. It now also asserts that the child is stillrunningand thatSLOW_ACKnever appears right after the abort.package.json:testrunsturbo run test --continue.Screenshots
Not applicable — no frontend changes.
Related issues
None.
Checklist
bun run lint,bun run typecheck,bun run testbun run e2e, orbun run e2e:fullwhen touching agent behavior) — not applicable, only tests and the test script changedSPEC.md/ top-level specs updated to reflect any boundary, contract, or behavior change — not applicable, no boundary, contract, or behavior changeTesting
bun test src/extension.test.ts -t "detached run SURVIVES" --rerun-each 30(pi-subagents) → 30 passbun test(pi-subagents) → 50 pass;bun test(extension-api) → 24 pass, the fallback test takes 0.06msbun run typecheck(repo-wide, after the rebase) → 20/20 tasks greenbun run lint(after the rebase) → cleanbun run test(full suite with--continue) → 20/20 tasks pass, run before rebasing onto two unrelatedorigin/maincommits (feat(web): redesign the topbar location strip as captioned segments #659 web, fix(server): reject malformed terminal and settings params #661 server)