Repository navigation
Stop two agent-runtime process-lifecycle tests from depending on process start speed - #8147
Merged
Merged
Conversation
"drains provider stderr before reporting process exit" spawned a grandchild that booted Node and then waited 50 ms before writing to the inherited stderr, while the provider exited at once. The runtime waits at most PROVIDER_PROCESS_CLOSE_GRACE_MS (1 s) after exit for stderr to close, so on a loaded runner Node startup alone overran the grace period and the exit callback saw no stderr. The grandchild now reports ready over IPC, the provider exits only then, and the grandchild writes 50 ms after the IPC channel disconnects. Co-Authored-By: Claude Opus 5.5 <[email protected]>
"does not wait for stalled replacement initialization during full shutdown" started and retired a full scripted-echo bridge before its stalled replacement, and that start and retirement took 3-12 s on loaded CI runners against a 15 s deadline. When it overran, the timed-out test body kept running after afterEach removed tmpDir and spawned the replacement into the missing cwd, which surfaced as an unhandled "spawn node ENOENT". The first process is now the idle child that #8136 and #8141 use for the sibling retirement tests; the stalled replacement still uses the real fake adapter so it receives initialize and holds its reply. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Human comments
What was wrong
Two tests in
packages/agent-runtime/src/runtime.process-lifecycle.test.tsfail at random inTests (packages-host)on loaded runners. Both depend on how fast processes start under CPU load.drains provider stderr before reporting process exitfails withexpected null to be 'stderr-after-exit', for example on #8075's merge run (job, 2286 ms). The fake provider spawned a grandchild that inherits stderr, then exited at once. The grandchild had to boot Node and wait 50 ms before writing. After a provider exits, the runtime waits at mostPROVIDER_PROCESS_CLOSE_GRACE_MS(1 s) for stderr to close. On a loaded runner, Node startup alone can take longer than that.does not wait for stalled replacement initialization during full shutdowntimes out at 15 s, followed by an unhandledProvider "fake" failed to start: spawn .../node ENOENT(job; it failed on all three attempts of that branch, and took 12.1 s on #8076's passing run). Before reaching its stalled replacement, the test started and retired a full scripted-echo bridge. #8141 measured a full start at 3.7–4.6 s under load, and stopping one can take up to 5 s plus kill and stderr grace periods. On other PRs' loaded runs the test took 3–12 s. When it overran, Vitest timed the test out but its body kept running.afterEachremovedtmpDir, and the replacement then spawned into the missing cwd, which Node reports asspawn <node> ENOENT. The ENOENT is a consequence of the timeout, not its cause. #8136 and #8141 fixed the sibling retirement tests the same way; this one was left.What changed
runtime.process-lifecycle.test.tsonly. No runtime code changes.process.stdin.resume(), no post-initialize requests) that the sibling tests use. The adapter it uses is pulled out into acreateIdleAdapterhelper thatcreateIdleProviderManagernow shares. The replacement still uses the real fake adapter on the raw stalled script, so it receivesinitializeand holds its reply for 3 s, which is the behavior under test.How you verified
CPU starvation locally: the test runs at background QoS (
taskpolicy -b) next to 32 busy-loop processes on a 16-core Mac. This reproduces both CI failures.Both tests still catch the bugs they guard:
PROVIDER_PROCESS_CLOSE_GRACE_MStemporarily set to 0, the new test fails 3 of 3.shutdown()temporarily changed to await in-flight provider starts, the new test fails.pnpm exec turbo run typecheck lint test --filter=@bb/agent-runtime: pass (316 tests, 1 skipped).🤖 Generated with Claude Code