Skip to content

docs: documenting async hooks features#13287

Closed
AndreasMadsen wants to merge 18 commits into
nodejs:masterfrom
AndreasMadsen:async-hooks-docs
Closed

docs: documenting async hooks features#13287
AndreasMadsen wants to merge 18 commits into
nodejs:masterfrom
AndreasMadsen:async-hooks-docs

Conversation

@AndreasMadsen
Copy link
Copy Markdown
Member

Checklist
Affected core subsystem(s)
  • async hooks
  • docs

This is a continuation on #12953 it should "fix" all the suggestions.

It took me 3 hours fix all the issues, so I would like if nits are done by you in a followup PR I simply don't have this much time. Also please be very specific with the suggestions, as in replace "this" with "this".

@nodejs-github-bot nodejs-github-bot added async_hooks Issues and PRs related to the async hooks subsystem. doc Issues and PRs related to the documentations. labels May 29, 2017
Copy link
Copy Markdown
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

LGTM modulo typos (if it helps I can fix them myself and push to this PR)

Comment thread doc/api/async_hooks.md Outdated

If any `AsyncHook` callbacks throw, the application will print the stack trace
and exit. The exit path does follow that of an uncaught exception but
all `uncaughtException` listeners are removed, thus forceing the process to
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo: forceingforcing

Comment thread doc/api/async_hooks.md Outdated
If any `AsyncHook` callbacks throw, the application will print the stack trace
and exit. The exit path does follow that of an uncaught exception but
all `uncaughtException` listeners are removed, thus forceing the process to
exit. The `'exit'` callbacks will still call unless the application is run with
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

callbe called

Comment thread doc/api/async_hooks.md Outdated

##### Printing in AsyncHooks callbacks

Because printing to the console is an asynchronous operations `console.log()`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo: operationsoperation

Comment thread doc/api/async_hooks.md Outdated
##### Printing in AsyncHooks callbacks

Because printing to the console is an asynchronous operations `console.log()`
will cause the AsyncHooks callbacks to write. Using `console.log()` or similar
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

writebe called

Comment thread doc/api/async_hooks.md Outdated

The `type` is a string that represents the type of resource that caused
`init()` to call. Generally it will be the name of the resource's constructor.
The resource types provided by the build in Node.js modules are:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo: build inbuilt-in

Comment thread doc/api/async_hooks.md Outdated
the user's callback is placed in a `process.nextTick()`.

The graph only shows **when** a resource was created. Not **why**. So to track
the **why** use `triggerId`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typos: created. Not **why**. So tocreated, not **why**, so to

Comment thread doc/api/async_hooks.md Outdated
For example:

```js
const server = net.createServer(conn => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we run the linter on docs now, so this might need to be (conn) instead of conn

Comment thread doc/api/async_hooks.md Outdated
* Returns {undefined}

Call all `before()` callbacks and let them know a new asynchronous execution
context is being entered. If nested calls to `emitBefore()` are made the stack
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

comma after made

Comment thread doc/api/async_hooks.md Outdated

* Returns {undefined}

Call all `after()` callbacks. If nested calls to `emitBefore()` were made then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

comma after made

Comment thread doc/api/async_hooks.md Outdated
make sure the stack is unwound properly. Otherwise an error will be thrown.

If the user's callback throws an exception then `emitAfter()` will
automatically be called for all `id`'s on the stack if the error is handled by
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove the apostrophe (`id`'s`id`s)

@AndreasMadsen
Copy link
Copy Markdown
Member Author

AndreasMadsen commented May 29, 2017

LGTM modulo typos (if it helps I can fix them myself and push to this PR)

that would be awesome as I will go to bed soon. For minor things, I find this much more helpful.

addaleax and others added 2 commits May 29, 2017 22:03