Skip to content

test(node-integration-tests): Surface early scenario exit instead of hanging#22136

Open
mydea wants to merge 2 commits into
developfrom
test/runner-surface-early-child-exit
Open

test(node-integration-tests): Surface early scenario exit instead of hanging#22136
mydea wants to merge 2 commits into
developfrom
test/runner-surface-early-child-exit

Conversation

@mydea

@mydea mydea commented Jul 9, 2026

Copy link
Copy Markdown
Member

When a scenario process exits before delivering the envelopes a test expects — e.g. it throws before sending its transaction, and the unhandled rejection exits the process with no envelope — the runner kept waiting until the vitest per-test timeout fired, reporting an opaque Test timed out in Nms with no child output. The runner's own 120s diagnostic dump never ran because the vitest timeout always beat it. This is why so many Docker/DB integration flakes surface as an uninformative timeout that only passes on retry.

Now the runner completes the moment the child closes early, with an error carrying the exit code/signal and how many envelopes arrived vs. were expected (plus a tail of the child's output in node-core, which has no separate log dump). Opaque multi-second timeouts become fast, diagnosable failures across every child-process integration suite.

It only fires for envelope-expecting tests that haven't completed: the success path has already called complete() (so this is a no-op), server-style (makeRequest) tests are killed by complete() first, and ensureNoErrorOutput / no-envelope tests are unaffected.

Verified locally: a scenario that throws before sending an envelope now fails in ~0.5s with Scenario exited (code 1) after 0/1 expected envelope(s), before the test completed. instead of hanging; normal envelope-then-exit suites (cron), server-style suites (httpIntegration-streamed), and the ANR suite (incl. should exit, which expects no envelopes) all still pass.

This does not by itself fix a specific flaky test — it makes the next occurrence diagnosable. In particular it unblocks root-causing the cron timeouts (#22112, #21891), whose real cause is currently hidden behind the opaque timeout.

🤖 Generated with Claude Code

mydea and others added 2 commits July 9, 2026 11:29
…hanging

When a scenario process exits before delivering the envelopes a test expects
(e.g. it throws before sending its transaction — an unhandled rejection exits
the process with no envelope), the runner previously kept waiting until the
vitest per-test timeout fired, reporting an opaque "Test timed out in Nms" with
no child output. The runner's own diagnostic dump never ran because the vitest
timeout always beat it.

Complete the test the moment the child closes early, with an error carrying the
exit code/signal and how many envelopes arrived vs were expected (plus a tail of
the child's output in node-core, which has no separate log dump). This turns
opaque multi-second timeouts into fast, diagnosable failures across every
Docker/child-process integration suite.

Only fires for envelope-expecting tests that have not completed: the success
path has already called `complete()` (so it is a no-op), server-style tests are
killed by `complete()` first, and `ensureNoErrorOutput`/no-envelope tests are
unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea mydea marked this pull request as ready for review July 9, 2026 11:18
@mydea mydea requested a review from a team as a code owner July 9, 2026 11:18
@mydea mydea requested review from JPeer264 and andreiborza and removed request for a team July 9, 2026 11:18

@andreiborza andreiborza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds super useful beyond just speeding failures up, nice!

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.

2 participants