Repository navigation
Conversation
runScriptOnce only disposed the VM and WASM runtime on the success path. Compile errors, synchronous throws, rejected promises, pending timeouts and pendingJobs failures all threw without cleanup, leaking WASM runtimes on repeated failures. Track every handle and dispose all of them plus vm/runtime in a finally block that runs on success, error and timeout alike. Once aborted, pending host-call callbacks no longer write into a VM that is about to be disposed. Add regression tests with a leak probe: after 25 script runs, assert every created runtime has alive === false (23/25 leaked before the fix, 0 after).
Move newContext() and runtime configuration inside try/finally so failures there cannot leak the WASM runtime. Track all three QuickJSDeferredPromise instances and dispose them on abort: an unsettled host promise otherwise leaves GC objects behind and vm.dispose() aborts with an assertion. Add regression tests for the pending-timeout path and for a host callback that settles only after the runtime was disposed (via guard). Include the shared test hooks loader and wire the suite into CI.
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.
Summary
runScriptOncedisposed the VM and WASM runtime only on the success path.Compile errors, synchronous throws, rejected promises, pending timeouts and
pendingJobs failures all threw without cleanup, leaking WASM runtimes on
repeated failures.
All handles are now tracked and disposed in a
finallyblock.newContext()and runtime configuration are inside that block too, so failures there cannot
leak the runtime. The three
QuickJSDeferredPromiseinstances are alsotracked: when a host promise never settles, leaving the deferred alive makes
vm.dispose()abort with a QuickJS GC assertion. Once aborted, pending hostcallbacks no longer write into a VM that is about to be disposed.
Tests
failure-then-success cases (unchanged from the original PR).
aborted guard and that no GC objects are left behind.
The Workers CI job now runs these Node tests.
Part of the split from the original combined PR. Uses the same test hooks
loader as the UserDO PR; no business-code dependency on it.