Repository navigation
test(vm): observe collected realms before asserting cancellation - #151
Merged
Merged
Conversation
steipete
marked this pull request as ready for review
October 9, 2026 17:11
This was referenced Oct 9, 2026
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.
The FinalizationRegistry fixture assumed that dropping four VM contexts meant one full collection had found all four realms dead. The scheduler only cancels pending work for unmarked realms, so a surviving context may legitimately run its cleanup job.
Adapts the FinalizationRegistry portion of oven-sh/bun#44544, currently open; thanks @robobun. Each dropped sandbox gets a WeakRef, checked synchronously after the existing full collection. The owning NodeVMGlobalObject strongly visits its sandbox, so a cleared witness establishes that its realm was unmarked. Every observed-collected realm must have zero callbacks. At least one of four must be collected: that exercises cancellation and prevents a vacuous pass without requiring a particular conservative-root layout.
The fixture also requires zero callbacks before the collection under test. It preserves the collection schedule, live-context completion, following turn, child exit/stderr checks, and the adjacent Atomics assertions. Production code is unchanged.
Validation:
cb8d6f202b5a396caa204ee1bb75d78175aa841a.JSCTaskScheduler::cancelWorkOfDeadRealmsdisabled, that same test fails. The runner reports its existing 5-second timeout; the recovered crash report matches the disabled executable UUID and records an ASAN abort throughrunPendingWork→JSFinalizationRegistry::runFinalizationCleanup→takeDeadHoldingsValue. Disassembly confirms the disabled function returns without cancellation. This is one failed negative-control invocation, not a retry-to-green.script-leak.test.tsexceeds its existing 5-second timeout (35.987 seconds). Its assertions and timeout have not been changed, and the failed suite has not been retried. The revised cancellation test passes within that suite.Exact-head native fork CI passes on Linux x64 and macOS ARM64. Linux reports 16 passing result entries, including 340 pass / 3 existing skip / 60 existing todo / 0 fail in
vm.test.ts. macOS reports 12 passing result entries, including 339 pass / 4 existing skip / 60 existing todo / 0 fail in the same file. CI merge commit53b3c165aa98fbd6e850493b1b7f4536fa128a12has exactly the same tree as PR head14898da7a6cf46c13c0b5ef282a9abd0f54a3118:187496412861ac8fbce891b58f6f1c6fe020c370.Formatting and JavaScript lint pass. The inherited issue-finding bot fails credential validation before code analysis; it has not been rerun. The supplementary full-directory debug timeout above remains a recorded limitation, not an all-tests-green claim. This test-only PR preserves every other assertion and makes no runtime changes.