Atomics.waitAsync(typedArray, index, value, timeout) is the non-blocking version of Atomics.wait(). Instead of putting the thread to sleep, it returns an object right away: { async, value }. If no waiting is needed, async is false and value is already the answer, "not-equal" or "timed-out". Otherwise async is true and value is a promise that resolves to "ok" when Atomics.notify() is called on the element, or "timed-out" after timeout milliseconds. Because nothing blocks, it may be used on the browser main thread. It is newer than wait() (ES2024) and not yet in every browser, so feature-detect it.
Remember
Atomics.waitAsync(typedArray, index, value) -> { async, value }
Atomics.waitAsync(typedArray, index, value, timeout)
{ async: false, value: "not-equal" } value already different
{ async: false, value: "timed-out" } timeout 0, nothing to wait for
{ async: true, value: Promise } resolves "ok" or "timed-out"
never blocks: fine on the browser main thread
feature-detect: typeof Atomics.waitAsync === "function"
Syntax
The arguments are the same as for Atomics.wait(); the difference is the result object.
Returns { async: true, value: promise } while the element equals value; the promise resolves to "ok" on notify. Returns { async: false, value: "not-equal" } otherwise.
The same, but the promise resolves to "timed-out" after timeout ms. A timeout of 0 gives { async: false, value: "timed-out" } immediately.
Added in ES2024. Chromium-based browsers have had it the longest; other engines added it later, so check typeof Atomics.waitAsync === "function" before using it. Node.js 24 supports it.
Library declarations
JavaScript
Atomics.waitAsync(typedArray, index, value, timeout)
// returns { async: false, value: "not-equal" | "timed-out" }
// or { async: true, value: Promise<"ok" | "timed-out"> }
// typedArray: Int32Array or BigInt64Array on a SharedArrayBuffer
// timeout: milliseconds, default Infinity
Parameters
Parameter
Description
typedArray
Required. An Int32Array or BigInt64Array on a SharedArrayBuffer. A normal buffer or another element type throws a TypeError, exactly as with wait().
index
Required. The element to watch. An invalid position throws a RangeError.
value
Required. The value that means “keep waiting”. If the element is already different, the result is "not-equal" straight away. Use a BigInt with a BigInt64Array.
timeout
Optional. Milliseconds before the promise gives up with "timed-out". The default is Infinity.
Return Value
Return Value
Description
{ async: false, value }
No waiting was needed: value is the string "not-equal" or "timed-out".
{ async: true, value }
value is a promise that resolves to "ok" (notified) or "timed-out".
JavaScript Examples
Example 1 — When the Answer Is Ready at Once
If the value already changed, or the timeout is 0, waitAsync() answers immediately with async: false.
This example needs SharedArrayBuffer and Atomics.waitAsync(). A normal browser tab is not cross-origin isolated, so the Try It page prints a short explanation and the output above. On a cross-origin isolated page it runs the code for real.
How It Works
A different value ends it early. Slot 0 holds 7, not 0, so there is nothing to wait for: async is false and value is "not-equal".
A zero timeout ends it too. Slot 1 does hold 0, but with a timeout of 0 the call gives up at once with "timed-out".
No promise was created. In both cases value is a plain string, which is why you read async first.
Example 2 — The Promise Resolves With "ok"
The value matches, so waitAsync() returns a pending promise. A notify() on the same slot settles it with "ok".
This example needs SharedArrayBuffer and Atomics.waitAsync(). A normal browser tab is not cross-origin isolated, so the Try It page prints a short explanation and the output above. On a cross-origin isolated page it runs the code for real.
How It Works
A real wait begins. Slot 0 is 0 as expected, so async is true and value is a promise (typeof says "object").
notify() counts the promise. A pending waitAsync() counts as a waiter, so notify() returns 1.
The callback runs afterwards.then() callbacks run after the current code finishes, so promise says: ok is printed last.
Example 3 — Await the Result, With a Timeout
An async function handles both shapes of the result and waits at most 10 ms. Nobody notifies, so the outcome is "timed-out".
JavaScript
const shared = new Int32Array(new SharedArrayBuffer(4));
const keepAlive = setTimeout(function () {}, 1000); // Node.js would exit early without it
async function waitForSignal() {
const result = Atomics.waitAsync(shared, 0, 0, 10);
console.log("waiting: " + result.async);
const outcome = result.async ? await result.value : result.value;
console.log("outcome: " + outcome);
clearTimeout(keepAlive);
}
waitForSignal();
This example needs SharedArrayBuffer and Atomics.waitAsync(). A normal browser tab is not cross-origin isolated, so the Try It page prints a short explanation and the output above. On a cross-origin isolated page it runs the code for real.
How It Works
Handle both result shapes. The conditional result.async ? await result.value : result.value works whether you got a promise or a ready string.
Ten quiet milliseconds. No thread calls notify(), so after 10 ms the promise resolves to "timed-out", and the page stays responsive the whole time.
Keep Node.js running. A pending waitAsync() timer does not keep Node.js alive, so the empty setTimeout holds the program open until the outcome is printed. Browsers do not need it.
Compatibility
Browser & Runtime Support
Atomics.waitAsync() was added in ES2024. Chromium-based browsers shipped it first; other engines followed later. It also needs SharedArrayBuffer.
✓ ES2024 · feature-detect
Atomics.waitAsync()
Available in Chrome, Edge, and other Chromium browsers and in Node.js (checked on version 24). Check other browsers before relying on it, and serve the page cross-origin isolated.
MostNot yet in every engine
Google ChromeSupported for several years · needs cross-origin isolation
Supported
Microsoft EdgeSupported (Chromium) · needs cross-origin isolation
Apple SafariAdded later than Chromium · needs cross-origin isolation
Check version
Mozilla FirefoxAdded later than Chromium · needs cross-origin isolation
Check version
Samsung InternetDepends on the Chromium base · needs cross-origin isolation
Check version
Internet ExplorerNo Atomics object
Not supported
Node.jsCurrent releases · checked on Node 24
Supported
DenoRecent releases
Check version
BunRecent releases
Check version
Atomics.waitAsync()Check your targets
Bottom line: Feature-detect with typeof Atomics.waitAsync === "function". Where it is missing, wait inside a Worker with Atomics.wait() and send the result back with postMessage().
Frequently Asked Questions
An object with two properties. If async is false, value is already "not-equal" or "timed-out". If async is true, value is a promise that resolves to "ok" or "timed-out".
wait() blocks the thread and returns a string. waitAsync() returns at once and gives you a promise for the outcome, so it can be used on the browser main thread.
No. Like wait(), it needs an Int32Array or BigInt64Array on a SharedArrayBuffer and throws a TypeError otherwise. In browsers that means a cross-origin isolated page.
A pending waitAsync() timeout does not keep the Node.js event loop alive. Keep the process busy, for example with a timer or a worker, until the promise resolves.
Test typeof Atomics.waitAsync === "function". It is an ES2024 addition and not every browser version has it.