Skip to content

fix(interopDefault): skip bind for Symbol.dispose/asyncDispose#444

Open
ruguoba wants to merge 2 commits into
unjs:mainfrom
ruguoba:fix/interop-default-symbol-bind
Open

fix(interopDefault): skip bind for Symbol.dispose/asyncDispose#444
ruguoba wants to merge 2 commits into
unjs:mainfrom
ruguoba:fix/interop-default-symbol-bind

Conversation

@ruguoba
Copy link
Copy Markdown

@ruguoba ruguoba commented May 20, 2026

Problem

V8 rejects binding well-known disposal symbols (Symbol.dispose and Symbol.asyncDispose) used by the TC39 Explicit Resource Management proposal. This causes errors when interopDefault proxy intercepts access to these symbols on module exports in Node.js 24+ with require(esm) syntax.

Fixes #441

Solution

Added a check in interopDefault to skip Reflect.bind for Symbol.dispose and Symbol.asyncDispose, since V8 does not allow binding these well-known symbols.

Testing

  • All existing tests pass (28/28)
    ✓ test/fixtures.test.ts (28 tests) 13868ms
    Test Files  1 passed (1)
         Tests  28 passed (28)
    
  • The explicit-resource-management fixture test passes successfully

Related

  • pi0"s comment on the original PR asking why it was closed
  • TC39 Explicit Resource Management proposal

V8 rejects binding well-known disposal symbols (Symbol.dispose and
Symbol.asyncDispose) used by the Explicit Resource Management proposal.
This causes errors when interopDefault proxy intercepts access to these
symbols on module exports in Node.js 24+ with using/await using syntax.

Fixes unjs#441
1.Refactor method binding logic in the interopDefault function: create wrapper functions for Symbol.dispose and Symbol.asyncDispose instead of direct binding

2.Add test cases for the Explicit Resource Management proposal to verify correct default export receiver behavior

3.Format the test matching path array in the Vitest configuration file for improved readability
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.

1 participant