From d34aacbb54a3e60bb16654cd14e6e93282a0479e Mon Sep 17 00:00:00 2001 From: Julian Soreavis Date: Sat, 18 Jul 2026 21:36:35 +0200 Subject: [PATCH] doc: fix triggerAsyncId() comment in async_hooks example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The connection-callback comment claims triggerAsyncId() returns the asyncId of "conn". It actually returns the server's own triggerAsyncId, because the callback runs in the execution scope of the server's MakeCallback() — as the sibling executionAsyncId() example already explains. Mirror that comment. Fixes: https://github.com/nodejs/node/issues/21078 Signed-off-by: Julian Soreavis --- doc/api/async_hooks.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index a863350fc2d26d..ad566239cf191a 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -814,9 +814,9 @@ See the section on [promise execution tracking][]. ```js const server = net.createServer((conn) => { - // The resource that caused (or triggered) this callback to be called - // was that of the new connection. Thus the return value of triggerAsyncId() - // is the asyncId of "conn". + // Returns the triggerAsyncId of the server, not of the new connection, + // because the callback runs in the execution scope of the server's + // MakeCallback(). async_hooks.triggerAsyncId(); }).listen(port, () => {