Skip to main content
executionAsyncId - node__async_hooks.d.ts - Node documentation
function executionAsyncId

Usage in Deno

```typescript import { executionAsyncId } from "node:node__async_hooks.d.ts"; ```
executionAsyncId(): number
> [!WARNING] Deno compatibility > The executionAsyncId implementation is a non-functional stub. ```js import { executionAsyncId } from 'node:async_hooks'; import fs from 'node:fs'; console.log(executionAsyncId()); // 1 - bootstrap const path = '.'; fs.open(path, 'r', (err, fd) => { console.log(executionAsyncId()); // 6 - open() }); ``` The ID returned from `executionAsyncId()` is related to execution timing, not causality (which is covered by `triggerAsyncId()`): ```js const server = net.createServer((conn) => { // Returns the ID of the server, not of the new connection, because the // callback runs in the execution scope of the server's MakeCallback(). async_hooks.executionAsyncId(); }).listen(port, () => { // Returns the ID of a TickObject (process.nextTick()) because all // callbacks passed to .listen() are wrapped in a nextTick(). async_hooks.executionAsyncId(); }); ``` Promise contexts may not get precise `executionAsyncIds` by default. See the section on [promise execution tracking](https://nodejs.org/docs/latest-v22.x/api/async_hooks.html#promise-execution-tracking).

Return Type

number
The `asyncId` of the current execution context. Useful to track when something calls.