Skip to main content
async_hooks - Node documentation

Usage in Deno

import * as mod from "node:async_hooks";

We strongly discourage the use of the async_hooks API. Other APIs that can cover most of its use cases include:

The node:async_hooks module provides an API to track asynchronous resources. It can be accessed using:

import async_hooks from 'node:async_hooks';

Classes

c
AsyncLocalStorage

This class creates stores that stay coherent through asynchronous operations.

c
AsyncResource

The class AsyncResource is designed to be extended by the embedder's asyncresources. Using this, users can easily trigger the lifetime events of theirown resources.

Functions

f
createHook

Registers functions to be called for different lifetime events of each asyncoperation.

f
executionAsyncId

The ID returned from executionAsyncId() is related to execution timing, notcausality (which is covered by triggerAsyncId()):

f
executionAsyncResource

Resource objects returned by executionAsyncResource() are most often internalNode.js handle objects with undocumented APIs. Using any functions or propertieson the object is likely to crash your application and should be avoided.

f
triggerAsyncId

Promise contexts may not get valid triggerAsyncIds by default. Seethe section on promise execution tracking.

Interfaces

I
AsyncHook
No documentation available
I
AsyncResourceOptions
No documentation available
I
HookCallbacks
No documentation available