node:async_hooks API Reference

Node.js async_hooks module — AsyncLocalStorage and AsyncResource (synchronous scope only)

Node.js async_hooks module, resolvable via both ESM import and CommonJS require. Implemented as a guest-JavaScript shim centred on AsyncLocalStorage.

Async context does not propagate across await. There is no promise-hook integration yet, so a store set with run / enterWith is visible only within the synchronous portion of the callback — it does not flow into await continuations, timers, or other asynchronous callbacks. createHook is a no-op. Treat AsyncLocalStorage here as synchronous-scope storage.

Implemented surface

ExportDescription
AsyncLocalStoragerun(store, fn), exit(fn), getStore(), enterWith(store), disable(), snapshot(), bind(fn) — synchronous scope only (see above).
AsyncResourcerunInAsyncScope(fn, thisArg, ...args), bind(fn), asyncId(), triggerAsyncId(), emitDestroy().
createHook(callbacks)Present as a no-op (returns a disabled hook).
executionAsyncId()Returns 1.
triggerAsyncId()Returns 0.
executionAsyncResource()The current execution resource.
asyncWrapProvidersThe provider-type constant map.

See also