8000 Asynchronously using a synchronous disposable that returns a Promise · Issue #256 · tc39/proposal-explicit-resource-management · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Asynchronously using a synchronous disposable that returns a Promise #256
Closed
@rictic

Description

@rictic

Should a promise returned by a Symbol.dispose method be awaited by AsyncDisposableStack#use / await using?

Put another way:

{
  const stack = new AsyncDisposableStack();
  const neverResolves = Promise.withResolvers().promise;
  stack.use({[Symbol.dispose]() { return neverResolves }});
  await stack.disposeAsync();
  console.log('[1] does this line of code ever run?'); 
}
{
  {
    const neverResolves = Promise.withResolvers().promise;
    await using _ = {[Symbol.dispose]: () => neverResolves};
  }
  console.log('[2] does this line of code ever run?');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No la 338B bels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0