doc: improve text in async_hooks.md

* Remove unnecessary *Note:* designations.
* Various small edits for tone, punctuation, etc.

PR-URL: https://github.com/nodejs/node/pull/19312
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Rich Trott 2018-03-12 20:35:14 -07:00
parent 5e23b65a87
commit 8d336dd8b1

View File

@ -246,9 +246,9 @@ instances and asynchronous work scheduled by them.
Users are able to define their own `type` when using the public embedder API. Users are able to define their own `type` when using the public embedder API.
*Note:* It is possible to have type name collisions. Embedders are encouraged It is possible to have type name collisions. Embedders are encouraged to use
to use unique prefixes, such as the npm package name, to prevent collisions unique prefixes, such as the npm package name, to prevent collisions when
when listening to the hooks. listening to the hooks.
###### `triggerId` ###### `triggerId`
@ -282,10 +282,10 @@ TCPWRAP(4): trigger: 2 execution: 0
The `TCPSERVERWRAP` is the server which receives the connections. The `TCPSERVERWRAP` is the server which receives the connections.
The `TCPWRAP` is the new connection from the client. When a new The `TCPWRAP` is the new connection from the client. When a new
connection is made the `TCPWrap` instance is immediately constructed. This connection is made, the `TCPWrap` instance is immediately constructed. This
happens outside of any JavaScript stack (side note: a `executionAsyncId()` of happens outside of any JavaScript stack. (An `executionAsyncId()` of `0` means
`0` means it's being executed from C++, with no JavaScript stack above it). that it is being executed from C++ with no JavaScript stack above it). With only
With only that information, it would be impossible to link resources together in that information, it would be impossible to link resources together in
terms of what caused them to be created, so `triggerAsyncId` is given the task terms of what caused them to be created, so `triggerAsyncId` is given the task
of propagating what resource is responsible for the new resource's existence. of propagating what resource is responsible for the new resource's existence.
@ -420,9 +420,9 @@ it only once.
Called immediately after the callback specified in `before` is completed. Called immediately after the callback specified in `before` is completed.
*Note:* If an uncaught exception occurs during execution of the callback, then If an uncaught exception occurs during execution of the callback, then `after`
`after` will run *after* the `'uncaughtException'` event is emitted or a will run *after* the `'uncaughtException'` event is emitted or a `domain`'s
`domain`'s handler runs. handler runs.
##### `destroy(asyncId)` ##### `destroy(asyncId)`
@ -432,11 +432,10 @@ Called immediately after the callback specified in `before` is completed.
Called after the resource corresponding to `asyncId` is destroyed. It is also Called after the resource corresponding to `asyncId` is destroyed. It is also
called asynchronously from the embedder API `emitDestroy()`. called asynchronously from the embedder API `emitDestroy()`.
*Note:* Some resources depend on garbage collection for cleanup, so if a Some resources depend on garbage collection for cleanup, so if a reference is
reference is made to the `resource` object passed to `init` it is possible that made to the `resource` object passed to `init` it is possible that `destroy`
`destroy` will never be called, causing a memory leak in the application. If will never be called, causing a memory leak in the application. If the resource
the resource does not depend on garbage collection, then this will not be an does not depend on garbage collection, then this will not be an issue.
issue.
##### `promiseResolve(asyncId)` ##### `promiseResolve(asyncId)`
@ -447,9 +446,8 @@ invoked (either directly or through other means of resolving a promise).
Note that `resolve()` does not do any observable synchronous work. Note that `resolve()` does not do any observable synchronous work.
*Note:* This does not necessarily mean that the `Promise` is fulfilled or The `Promise` is not necessarily fulfilled or rejected at this point if the
rejected at this point, if the `Promise` was resolved by assuming the state `Promise` was resolved by assuming the state of another `Promise`.
of another `Promise`.
```js ```js
new Promise((resolve) => resolve(true)).then((a) => {}); new Promise((resolve) => resolve(true)).then((a) => {});