Skip to content

fix(runtime): support disposable symbols without native definitions - #151

Merged
paralin merged 1 commit into
masterfrom
fix/webkit-disposable-symbol
Aug 12, 2026
Merged

fix(runtime): support disposable symbols without native definitions#151
paralin merged 1 commit into
masterfrom
fix/webkit-disposable-symbol

Conversation

@paralin

@paralin paralin commented Aug 12, 2026

Copy link
Copy Markdown
Member

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.

Copilot AI lite review requested due to automatic review settings August 12, 2026 07:08
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
paralin force-pushed the fix/webkit-disposable-symbol branch from 28abe74 to 799dd36 Compare August 12, 2026 07:09
@paralin
paralin merged commit a2a6b1f into master Aug 12, 2026
7 of 8 checks passed
@paralin
paralin deleted the fix/webkit-disposable-symbol branch August 12, 2026 07:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 using and 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 () => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants