Skip to content

Gap: await using (Symbol.asyncDispose / ES2024 explicit resource management) #154

Closed

Description

@proggeramlug

Summary

test-files/test_gap_async_advanced.ts (line 180-201) exercises await using with [Symbol.asyncDispose]() — the ES2024 explicit-resource-management proposal. Perry silently accepts the syntax but never runs the dispose hook.

Repro

async function test() {
  const disposed: string[] = [];
  class AsyncResource {
    name: string;
    constructor(name: string) { this.name = name; }
    async [Symbol.asyncDispose](): Promise<void> {
      await new Promise<void>((r) => setTimeout(r, 1));
      disposed.push(this.name);
    }
  }
  {
    await using r1 = new AsyncResource("res1");
    await using r2 = new AsyncResource("res2");
  }
  console.log(disposed.join(",")); // expected "res2,res1"
}

Actual vs Expected

  • Perry: "" (dispose never ran)
  • Node: "res2,res1" (disposed in reverse declaration order)

Scope

  • Parse / lower await using and using binding forms
  • Attach an implicit dispose queue per block scope; register each binding's [Symbol.asyncDispose]() on creation
  • On block exit (success OR exception), await each registered disposer in reverse order, then re-throw any exception with SuppressedError chaining
  • Synchronous using dispatches to [Symbol.dispose](); async dispatches to [Symbol.asyncDispose]()

Impact

One of six currently-failing gap tests (post v0.5.173, baseline 22/28 passing). Only this feature blocks test_gap_async_advanced from passing — everything else in that file works.

Activity

  1. added a commit that references this issue on Apr 26, 2026
  2. added 5 commits that reference this issue on Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions