Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add entry for AsyncHook class #31865

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup: address review comment
  • Loading branch information
HarshithaKP committed Feb 21, 2020
commit 88cc03971cd9a811234892922ecfaf860fdbe8b2
13 changes: 7 additions & 6 deletions doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ function destroy(asyncId) { }
// (either directly or through other means of resolving a promise).
function promiseResolve(asyncId) { }
```
### Class: `AsyncHook`

The class `AsyncHook` exposes interface for tracking lifetime events
of asynchronous operations. Using a unique ID per asynchronous call,
it helps associating method calls that otherwise do not appear in a
typical call stack.

#### `async_hooks.createHook(callbacks)`

Expand Down Expand Up @@ -176,6 +170,13 @@ provided by AsyncHooks itself. The logging should then be skipped when
it was the logging itself that caused AsyncHooks callback to call. By
doing this the otherwise infinite recursion is broken.

### Class: `AsyncHook`

The class `AsyncHook` exposes interface for tracking lifetime events
of asynchronous operations. Using a unique ID per asynchronous call,
it helps associating method calls that otherwise do not appear together
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either

Suggested change
it helps associating method calls that otherwise do not appear together
it helps with associating method calls that otherwise do not appear together

or

Suggested change
it helps associating method calls that otherwise do not appear together
it helps associate method calls that otherwise do not appear together

That being said – what’s a typical call stack?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addaleax , I used typical here to mean a representative call stack on node.js program error. As per my understanding, a representative stack is a incomplete part of an asynchronous sequence. Am I wrong?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HarshithaKP I’m still confused… That kind of only moves the question from “what’s a typical call stack?” to “what’s a representative call stack?”.

To be honest, I think it’s okay to drop the second sentence here. The sentence is not accurate anyway, the IDs are unique per asynchronous resource but not per asynchronous call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addaleax, dropped the second sentence.

in a typical call stack.

#### `asyncHook.enable()`

* Returns: {AsyncHook} A reference to `asyncHook`.
Expand Down