node:async_hooks
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
| Export | Description |
|---|---|
AsyncLocalStorage | run(store, fn), exit(fn), getStore(), enterWith(store), disable(), snapshot(), bind(fn) — synchronous scope only (see above). |
AsyncResource | runInAsyncScope(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. |
asyncWrapProviders | The provider-type constant map. |
See also
- Node.js upstream: