fix(runtime): support disposable symbols without native definitions - #151
Merged
Conversation
WebKit lacks native Symbol.dispose and Symbol.asyncDispose symbols, while Bun lowered using declarations look up the registry fallbacks from Symbol.for. The runtime methods were registered only under missing native keys, so generated disposal could not reach them. Resolve the native or registry key once for each symbol and use those keys for both disposable stacks. The browser fixture builds Bun lowered using code and covers Chromium and WebKit, LIFO cleanup, async cleanup, and deferred error propagation. Native Chromium behavior and the public runtime API remain unchanged. Signed-off-by: Christian Stewart <christian@aperture.us>
paralin
force-pushed
the
fix/webkit-disposable-symbol
branch
from
August 12, 2026 07:09
28abe74 to
799dd36
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the GoScript runtime’s DisposableStack / AsyncDisposableStack to work in engines that lack native Symbol.dispose / Symbol.asyncDispose by falling back to registry symbols, and adds a browser regression test to validate LIFO cleanup, async cleanup, and deferred error propagation across Chromium and WebKit.
Changes:
- Add runtime symbol resolution (
Symbol.dispose ?? Symbol.for('Symbol.dispose'), likewise for async) and key the stack disposal methods off those resolved symbols. - Add a small browser bundle entry that exercises
using/await usingand captures observed disposal behavior. - Add a Vitest test that bundles the browser entry with Bun and executes it under Playwright Chromium/WebKit.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| gs/builtin/defer.ts | Resolves dispose symbols via native-or-registry fallback and uses them for the stack disposal methods. |
| gs/builtin/testdata/disposable-stack-browser.ts | Browser entrypoint that runs using / await using scenarios and returns a structured result. |
| gs/builtin/defer-browser.test.ts | Bundles the browser entry and validates expected behavior in Playwright Chromium and WebKit. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+7
to
+8
| import { chromium, webkit } from 'playwright' | ||
| import { afterAll, describe, expect, it } from 'vitest' |
| ['Chromium', chromium], | ||
| ['WebKit', webkit], | ||
| ])('DisposableStack in %s', (_name, browserType) => { | ||
| it('supports generated using declarations', async () => { |
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.
Resolve Symbol.dispose and Symbol.asyncDispose through the registry names when a browser lacks native symbols. This keeps native Chromium symbols unchanged and lets Bun lowered using and await using code dispose GoScript stacks in WebKit. The focused Chromium and WebKit regression checks LIFO cleanup, async cleanup, and deferred errors.