Skip to content

Atomics.waitAsync does not bind to event loop #15358

Open
@aapoalas

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlydeno_coreChanges in "deno_core" crate are needed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions