-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
🔎 Search Terms
using
🕗 Version & Regression Information
I assume it is in every version that using has been implemented
⏯ Playground Link
💻 Code
(async () => {
const log = [];
const promiseDispose = new Promise((resolve, _) => {
setTimeout(() => {
log.push("y dispose promise body");
resolve();
}, 0);
});
{
await using x = {
async [Symbol.asyncDispose = Symbol.for("Symbol.asyncDispose")]() {
log.push("x asyncDispose body");
},
};
await using y = {
[Symbol.dispose = Symbol.for("Symbol.dispose")]() {
log.push("y dispose body");
return promiseDispose;
},
};
}
log.push("body");
await promiseDispose;
console.log(log);
})();🙁 Actual behavior
It logs ["y dispose body", "y dispose promise body", "x asyncDispose body", "body"]
🙂 Expected behavior
It should log ["y dispose body", "x asyncDispose body", "body", "y dispose promise body"].
The "y dispose promise body" should be printed in the next event cycle, however it is printed before x asyncDispose body because the promise is awaited when disposing y.
Additional information about the issue
Per 7.5.6 GetDisposeMethod
NOTE: This function is not observable to user code. It is used to ensure that a Promise returned from a synchronous dispose method will not be awaited.
cc @rbuckton
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue