Skip to content

Add WeakSet to prevent double dispose #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

timursevimli
Copy link
Member

Manually calling console[Symbol.asyncDispose]() caused a double dispose (disposing the resource twice), leading to errors and unstable behavior.

In earlier versions, the following example did not work correctly:

 // Block 0
 {
    await using console = logger.use();
    console.log('Log 1');

    // Manually calling dispose causes double dispose error:
    console[Symbol.asyncDispose]();

    // Block 1
    {
      await using console = logger.use();
      console.log('Log 1');
    }
    // Block 2
    {
      await using console = logger.use();
      console.log('Log 2');
    }
    await timers.setTimeout(1000);
  }

The above example now works without issues, and double dispose errors are prevented.

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