While we intend to maintain the consensus that an evaluated await using will always imply an implicit Await at the end of the block, it was suggested that the return value of a synchronous [Symbol.dispose]() method shouldn't itself be Await-ed, even if that method returns a Promise so as to remain consistent with the synchronous using statement.
The following is are examples of the current behavior and the suggested behavior:
Current behavior
{
using x = { [Symbol.dispose]() { return Promise.reject(new Error("x")); } };
} // return value ignored, does not throw on block exit
{
await using y = { [Symbol.dispose]() { return Promise.reject(new Error("y")); } };
} // implicit `await` for return value, throws Error("y") on block exit
Suggested behavior
{
using x = { [Symbol.dispose]() { return Promise.reject(new Error("x")); } };
} // return value ignored, does not throw on block exit
{
await using y = { [Symbol.dispose]() { return Promise.reject(new Error("y")); } };
} // implicit `await undefined`, return value ignored, does not throw on block exit
While we intend to maintain the consensus that an evaluated
await usingwill always imply an implicitAwaitat the end of the block, it was suggested that the return value of a synchronous[Symbol.dispose]()method shouldn't itself beAwait-ed, even if that method returns aPromiseso as to remain consistent with the synchronoususingstatement.The following is are examples of the current behavior and the suggested behavior:
Current behavior
Suggested behavior