Node.js API compatibility - Async hooks
This documentation explores how the Node.js async_hooks API can be effectively utilized within the Azion Runtime environment. The async_hooks module in Node.js enables developers to monitor the lifecycle of asynchronous operations.
The async_hooks library in Node.js allows developers to track the lifecycle of asynchronous resources. It provides hooks that trigger at different stages of an asynchronous operation, enabling context propagation and better debugging. In the Azion Runtime, it’s available through Node.js compatibility, and AsyncLocalStorage is a common use case for carrying request-scoped data, such as a request ID, across asynchronous calls in a function.
The example below shows how to use the async_hooks module in a function: