Skip to content

Commit 922d4c4

Browse files
soreavisaduh95
authored andcommitted
doc: fix triggerAsyncId() comment in async_hooks example
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: #21078 Signed-off-by: Julian Soreavis <julian.soreavis@gmail.com> PR-URL: #64583 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 5b4521f commit 922d4c4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

doc/api/async_hooks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,9 @@ See the section on [promise execution tracking][].
814814
815815
```js
816816
const server = net.createServer((conn) => {
817-
// The resource that caused (or triggered) this callback to be called
818-
// was that of the new connection. Thus the return value of triggerAsyncId()
819-
// is the asyncId of "conn".
817+
// Returns the triggerAsyncId of the server, not of the new connection,
818+
// because the callback runs in the execution scope of the server's
819+
// MakeCallback().
820820
async_hooks.triggerAsyncId();
821821

822822
}).listen(port, () => {

0 commit comments

Comments
 (0)