Skip to content

🤖 tests: wait for background exits instead of fixed sleeps before reading output - #5607

Merged
ThomasK33 merged 1 commit into
mainfrom
tests/5606-recreated-tools-output
Oct 4, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
tests/5606-recreated-tools-output

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

Five tests in tests/ipc/runtime/backgroundBashDirect.test.ts started a short background command, slept a fixed 200 to 500 ms, then read its output once and expected all of it. On Windows CI the command can start writing later than that. The read then returned "", which is the #5606 failure. Each test now waits for the process to exit, using the waitForProcessExit helper added in #5595 (bounded at 10 s), and then reads. This is a test-only change.

Fixes #5606

Root cause

In run 37169294244 (Test / Windows, merge group at f0ad3c6), "should retrieve output after tools are recreated (multi-message flow)" spawned echo "MULTI_MSG_…" in the background, waited 200 ms, then read with a new bash_output tool. It received "".

Nothing lost the output. The read simply came before the slow Windows process start had written anything. Once the process exits, a newly created tool instance reads the full output. The fixed test shows this: it still reads through a recreated bash_output. So no product fix is needed.

The same pattern (a fixed sleep, then one read expecting complete output) was in four sibling tests: "should read output files via handle", "should capture stderr output when process exits with error" (which also expects the exit code), "should capture output when script fails mid-execution", and "should handle long-running script that outputs to both streams". I fixed them the same way.

Validation

  • Reproduced on Linux with a probe (not committed) that delays every background spawn by 0.5 s (sleep 0.5; before the script), standing in for a slow Windows process start. On main, 4 tests fail, including the exact CI symptom:

    ● Background Bash Direct Integration › should retrieve output after tools are recreated (multi-message flow)
      Expected substring: "MULTI_MSG_…"
      Received string:    ""
    ● … › should read output files via handle (works for SSH runtime)   Received string: ""
    ● Background Bash Output Capture › should capture stderr output when process exits with error   Expected: 1, Received: undefined
    ● … › should capture output when script fails mid-execution   Received string: ""
    

    With this change and the same probe, all 11 tests pass.

  • Without the probe, the file passes (11 tests, bun x jest, Bun 1.3.12). make static-check passes.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $53.84

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T02:14:09.401607Z ed475c8 PR opened
🔒 Security Review ✅ Completed 2026-10-04T02:16:05.238235Z ed475c8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ThomasK33

Copy link
Copy Markdown
Member Author

Readiness record for head ed475c8:

  • CI: all required checks pass on this head (26 pass, 4 skipped). Test / Windows ran backgroundBashDirect.test.ts and passed (42 tests in that job). The only open item is the optional Pixel / Review. Unresolved threads: 0.
  • Local: make static-check passes, and the file passes (11 tests). A probe that delays every background start by 0.5 s makes 4 tests fail on main (including the exact CI symptom), and all 11 pass on this branch.
  • Review budget: 3 of 6 assessments (1 normal and 1 security automatic review, both with no findings, plus the final check).
  • Final independent check (clean context, on exactly this head): "ready with tracked follow-ups". No blocker and no required follow-up. It confirmed two things: "exited" means the output is complete (the EXIT trap writes exit_code after the script's last write), and the read cursors live in the manager, so a recreated tool cannot miss output. Optional only: make waitForProcessExit assert that the process exists.
  • Decision: ready. Merging with squash, pinned to this head.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $53.84

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 4, 2026
Merged via the queue into main with commit 7df57a6 Oct 4, 2026
30 of 31 checks passed
@ThomasK33
ThomasK33 deleted the tests/5606-recreated-tools-output branch October 4, 2026 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🤖 tests: flaky Windows backgroundBashDirect 'retrieve output after tools are recreated' (empty output)

1 participant