You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Promise returned from sync dispose method should not be awaited when disposing an asyc-disposable #58077
(async()=>{constlog=[];constpromiseDispose=newPromise((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");returnpromiseDispose;},};}log.push("body");awaitpromiseDispose;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.
Activity
rbuckton commentedon Apr 4, 2024
Thanks, I plan to fix this shortly along with several other small normative changes up for discussion at next week's TC39 plenary.