doc: fix triggerAsyncId() comment in async_hooks example#64583
Open
soreavis wants to merge 1 commit into
Open
Conversation
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: nodejs#21078 Signed-off-by: Julian Soreavis <julian.soreavis@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
triggerAsyncId()example's connection-callback comment claims the return value "is the asyncId ofconn". It isn't, and never was: the callback runs in the execution scope of the server'sMakeCallback(), sotriggerAsyncId()returns the server's own triggerAsyncId — measured by the reporter on v8/v10 in #21078 and re-verified on currentmain(server asyncId 2/trigger 1, conn asyncId 10: the callback seestriggerAsyncId() === 1,executionAsyncId() === 2). The siblingexecutionAsyncId()example above has stated the correct pattern since the original async_hooks docs (#13287); this mirrors its comment. In #21078, @apapirovski noted the docs don't match reality and @addaleax confirmed "a documentation change would definitely suffice".Scoped to the inline comment — the only text that contradicts reality. The section's definition line and the
.listen()comment are correct and untouched; verified againstsrc/connection_wrap.cc(OnConnectionfires the server wrap'sMakeCallback) andsrc/async_wrap.cc/src/api/callback.cc(push_async_contextreceives the server's own asyncId/triggerAsyncId pair). Comment-only precedent in this file: #42499.I used an AI assistant while researching and drafting this change; I've verified the behavior and the wording against the source and a live repro myself and take full responsibility for it.
Fixes: #21078