fix: stop test teardowns from silently killing the bun test run#2172
Open
sneakygriff wants to merge 1 commit into
Open
fix: stop test teardowns from silently killing the bun test run#2172sneakygriff wants to merge 1 commit into
sneakygriff wants to merge 1 commit into
Conversation
Several browse and design test files armed `setTimeout(() => process.exit(0), 500)` inside afterAll as a workaround for a browser close() that can hang. That assumes each test file runs in its own process. It doesn't: `bun test` runs EVERY file in one shared process. The 500ms timer therefore fired partway through a LATER test file and terminated the entire run with exit code 0 and no summary. Because the exit code was 0, the suite could not gate — only a fraction of the files ran, and every downstream failure was silently masked. The fix removes the delayed process.exit from teardown and instead time-boxes the resource cleanup: browser teardowns race `close()` against a short timeout and abandon it if it hangs (the child is reaped at real process exit), and the design daemon /shutdown test stubs `process.exit` around the shutdown timers so they fire harmlessly. A new static-guard test, test/no-suicide-exit.test.ts, scans every *.test.ts and fails if any file schedules a delayed process.exit, so the pattern cannot silently return. test/user-slug-fallback.test.ts is made deterministic via HOME isolation. Verified: test/no-suicide-exit.test.ts + test/user-slug-fallback.test.ts pass (15/15); browse/test/commands.test.ts passes standalone (243/243) and now runs to a full summary; design/test/daemon.test.ts passes (34/34) with no early exit. Honest note: with the suite now able to run to completion, it surfaces pre-existing failures that the early exit had been hiding — e.g. design/test/feedback-roundtrip.test.ts fails identically on unmodified origin/main (a `session.clearLoadedHtml` stub gap), independent of this change. These are not introduced here; this change only makes them visible so they can be gated on and fixed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
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
Several
browse/anddesign/test files armedsetTimeout(() => process.exit(0), 500)insideafterAll— a workaround for a browserclose()that can hang. That assumes each test file runs in its own process. It doesn't:bun testruns every file in one shared process. The 500ms timer therefore fired partway through a later test file and terminated the entire run with exit code 0 and no summary.Because the exit code was 0, the suite could not gate: only a fraction of the files ran, and every downstream failure was silently masked.
Fix
process.exitfrom teardown; instead time-box resource cleanup. Browser teardowns raceclose()against a short timeout and abandon it if it hangs (the child is reaped at real process exit). The design daemon/shutdowntest stubsprocess.exitaround the shutdown timers so they fire harmlessly.test/no-suicide-exit.test.ts, a static guard that scans every*.test.tsand fails if any file schedules a delayedprocess.exit, so the pattern cannot silently return.test/user-slug-fallback.test.tsdeterministic via HOME isolation.Verification
bun test test/no-suicide-exit.test.ts test/user-slug-fallback.test.ts— 15 pass, 0 fail (guard green + slug 14/14).bun test browse/test/commands.test.ts— 243 pass, 0 fail, now runs to a full summary.bun test design/test/daemon.test.ts— 34 pass, 0 fail, no early exit.Honest note
With the suite now able to run to completion, it surfaces pre-existing failures that the early exit had been hiding — for example
design/test/feedback-roundtrip.test.tsfails identically on unmodifiedorigin/main(asession.clearLoadedHtmlstub gap), independent of this change. Those failures are not introduced by this PR; this change only makes them visible so they can be gated on and fixed in follow-ups.🤖 Generated with Claude Code