Open
Description
The waitAsync
call does not bind to Tokio event loop in any way. Deno has no idea that waitAsync
is creates a Promise that should be polled nor that the Promise should keep Deno from exiting.
As a result, this code will exit with a warning about pending ops:
// mod.ts
const sab = new SharedArrayBuffer(4);
const int32 = new Int32Array(sab);
await Atomics.waitAsync(int32, 0, 0, 2).value;
An alternative method to verify the bug is to open REPL, setup the int32
buffer as above, and then do repeated calls like this, one at at ime:
let i = 0; // Only init this once
Atomics.waitAsync(int32, 0, 0, 2).value.then(() => console.log(`Call ${++i}`));
One would expect the first call to be quickly followed by a log Call 1
but instead no log appears. After the second call the Call 1
appears, while Call 2
appears only after the third call etc.
Activity