Skip to content

Explicit resource management still not working natively due to SWC transpilation #29031

@nktpro

Description

@nktpro

Version: Deno 2.2.11

Despite --js-explicit-resource-management v8 flag enabled by default since 2.2.10, the (now obsolete) explicit_resource_management SWC transpilation transformer was not disabled for TypeScript sources. Consequently, TypeScript scripts run with deno still do not benefit from this natively.

Here's a reproducer:

// test.ts
try {
  using _foo = {
    [Symbol.dispose]() {
      throw new Error("foo");
    },
  };

  throw new Error("bar");
} catch (e) {
  console.log(e);
}
deno run test.ts

Outputs:

SuppressedError: An error was suppressed during disposal.
    at fail (file:///test.ts:41:34)
    at next (file:///test.ts:57:11)
    at _ts_dispose_resources (file:///test.ts:63:12)
    at _ts_dispose_resources (file:///test.ts:64:5)
    at file:///test.ts:8:19

The stack trace clearly shows transpiled code with _ts_dispose_resources, which comes from SWC helpers, so the disposal execution actually doesn't leverage v8 natively at all.

On the other hand, if we rename test.ts to test.js, no transpilation occurs, and it works natively as expected:

deno run test.js

Outputs:

SuppressedError: An error was suppressed during disposal
    at file:///test.js:8:3

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamChanges in upstream are required to solve these issuesv8Bugs in upstream v8

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions