-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix stale exception when a lazy property initializer throws during property enumeration #37158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 The test sets
stderr: "pipe"but never drains it — onlyproc.stdout.text()andproc.exitedare awaited. Match the neighboring "huge sparse array" test and REVIEW.md's subprocess rule:const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]), then assert the combined{ stdout: stdout.trim(), stderr, exitCode }object. Otherwise a regression that reintroduces the debug abort will show onlyreceived ""with the stderr backtrace silently discarded.Extended reasoning...
What the bug is
The new test at
test/js/bun/util/inspect.test.js:823-830spawns a subprocess withstderr: "pipe"but only awaitsproc.stdout.text()andproc.exited:The
stderrpipe is opened but never read. REVIEW.md rejects this pattern explicitly under Tests reviewers reject → Subprocess tests: drain pipes concurrently: "Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited])— an unread pipe fills the ~64KB OS buffer and deadlocks the child. assert a combined{ stdout, stderr, exitCode }object."Why local convention also demands it
The immediately neighboring subprocess test in the same file —
"Bun.inspect huge sparse array summarizes holes without iterating them"— follows the correct pattern exactly:REVIEW.md separately requires "Match the exact file's local conventions", so this test diverges from both the repo-wide rule and the pattern established a few lines above it.
Step-by-step: what goes wrong on a regression
The whole point of this test is to catch a regression of the debug-build abort described in the PR (
ASSERTION FAILED: Unexpected exception observed). Walk through what happens if that abort comes back:globalThis.Symbol = 0; Bun.inspect(Bun);— the lazyBun.$callback throws, the stale exception leaks, and the debug build aborts with a JSC assertion."OK 2"to stdout.stdout→"", andexitCode→ non-zero (or a signal).expect(stdout.trim()).toBe("OK 2")— Expected"OK 2", Received"".The actual diagnostic — the assertion text and backtrace on stderr — is silently discarded because nothing ever read the pipe. Whoever debugs the CI failure has no idea why the child died. With the combined-object assertion, the failure output would instead show
stderr: "ASSERTION FAILED: Unexpected exception observed... <backtrace>"andexitCode: <signal>, which is exactly the signal you want.Deadlock direction
Bun.inspect(Bun)reifies every lazy property on the Bun object; withSymbolclobbered several of these ($,sql,postgres,SQL) throw during reification. In the current passing path stderr stays empty, so the ~64KB pipe-buffer deadlock does not occur today. But the pattern is what REVIEW.md rejects regardless — if any of those reification paths (or a future warning) becomes noisy on stderr, the child could block writing to a full pipe while the parent only drains stdout.Fix
One-line change to match the neighboring test:
Severity
Nit. The test passes as written and nothing concretely breaks today — the deadlock risk is theoretical for this particular script, and the diagnostic loss only bites on a future regression. But it violates an explicit repo review rule, diverges from the immediate neighboring convention, and the fix is trivial.