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 withrun/enterWithis visible only within the synchronous portion of the callback — it does not flow intoawaitcontinuations, timers, or other asynchronous callbacks.createHookis a no-op. TreatAsyncLocalStoragehere 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: https://nodejs.org/api/async_hooks.html