Skip to content

Commit 8f08d66

Browse files
maclover7MylesBorins
authored andcommitted
doc: async_hooks grammar nits
PR-URL: #16361 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent b96d76f commit 8f08d66

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

doc/api/async_hooks.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ operation.
9292
The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
9393
respective asynchronous event during a resource's lifetime.
9494

95-
All callbacks are optional. So, for example, if only resource cleanup needs to
96-
be tracked then only the `destroy` callback needs to be passed. The
97-
specifics of all functions that can be passed to `callbacks` is in the section
98-
[Hook Callbacks][].
95+
All callbacks are optional. For example, if only resource cleanup needs to
96+
be tracked, then only the `destroy` callback needs to be passed. The
97+
specifics of all functions that can be passed to `callbacks` is in the
98+
[Hook Callbacks][] section.
9999

100100
```js
101101
const async_hooks = require('async_hooks');
@@ -125,7 +125,7 @@ const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
125125
##### Error Handling
126126

127127
If any `AsyncHook` callbacks throw, the application will print the stack trace
128-
and exit. The exit path does follow that of an uncaught exception but
128+
and exit. The exit path does follow that of an uncaught exception, but
129129
all `uncaughtException` listeners are removed, thus forcing the process to
130130
exit. The `'exit'` callbacks will still be called unless the application is run
131131
with `--abort-on-uncaught-exception`, in which case a stack trace will be
@@ -173,7 +173,7 @@ doing this the otherwise infinite recursion is broken.
173173
Enable the callbacks for a given `AsyncHook` instance. If no callbacks are
174174
provided enabling is a noop.
175175

176-
The `AsyncHook` instance is by default disabled. If the `AsyncHook` instance
176+
The `AsyncHook` instance is disabled by default. If the `AsyncHook` instance
177177
should be enabled immediately after creation, the following pattern can be used.
178178

179179
```js
@@ -196,7 +196,7 @@ For API consistency `disable()` also returns the `AsyncHook` instance.
196196

197197
Key events in the lifetime of asynchronous events have been categorized into
198198
four areas: instantiation, before/after the callback is called, and when the
199-
instance is destructed.
199+
instance is destroyed.
200200

201201
##### `init(asyncId, type, triggerAsyncId, resource)`
202202

@@ -283,7 +283,7 @@ The second `TCPWRAP` is the new connection from the client. When a new
283283
connection is made the `TCPWrap` instance is immediately constructed. This
284284
happens outside of any JavaScript stack (side note: a `executionAsyncId()` of `0`
285285
means it's being executed from C++, with no JavaScript stack above it).
286-
With only that information it would be impossible to link resources together in
286+
With only that information, it would be impossible to link resources together in
287287
terms of what caused them to be created, so `triggerAsyncId` is given the task of
288288
propagating what resource is responsible for the new resource's existence.
289289

@@ -295,8 +295,8 @@ the value of `type`. For instance, for the `GETADDRINFOREQWRAP` resource type,
295295
`resource` provides the hostname used when looking up the IP address for the
296296
hostname in `net.Server.listen()`. The API for accessing this information is
297297
currently not considered public, but using the Embedder API, users can provide
298-
and document their own resource objects. Such a resource object could for
299-
example contain the SQL query being executed.
298+
and document their own resource objects. For example, such a resource object
299+
could contain the SQL query being executed.
300300

301301
In the case of Promises, the `resource` object will have `promise` property
302302
that refers to the Promise that is being initialized, and a `parentId` property
@@ -385,7 +385,7 @@ Only using `execution` to graph resource allocation results in the following:
385385
TTYWRAP(6) -> Timeout(4) -> TIMERWRAP(5) -> TickObject(3) -> root(1)
386386
```
387387

388-
The `TCPWRAP` is not part of this graph; even though it was the reason for
388+
The `TCPWRAP` is not part of this graph, even though it was the reason for
389389
`console.log()` being called. This is because binding to a port without a
390390
hostname is a *synchronous* operation, but to maintain a completely asynchronous
391391
API the user's callback is placed in a `process.nextTick()`.
@@ -408,7 +408,7 @@ The `before` callback will be called 0 to N times. The `before` callback
408408
will typically be called 0 times if the asynchronous operation was cancelled
409409
or, for example, if no connections are received by a TCP server. Persistent
410410
asynchronous resources like a TCP server will typically call the `before`
411-
callback multiple times, while other operations like `fs.open()` will only call
411+
callback multiple times, while other operations like `fs.open()` will call
412412
it only once.
413413

414414

@@ -418,7 +418,7 @@ it only once.
418418

419419
Called immediately after the callback specified in `before` is completed.
420420

421-
*Note:* If an uncaught exception occurs during execution of the callback then
421+
*Note:* If an uncaught exception occurs during execution of the callback, then
422422
`after` will run *after* the `'uncaughtException'` event is emitted or a
423423
`domain`'s handler runs.
424424

@@ -568,10 +568,9 @@ asyncResource.triggerAsyncId();
568568

569569
#### `AsyncResource(type[, triggerAsyncId])`
570570

571-
* arguments
572-
* `type` {string} The type of async event.
573-
* `triggerAsyncId` {number} The ID of the execution context that created this
574-
async event.
571+
* `type` {string} The type of async event.
572+
* `triggerAsyncId` {number} The ID of the execution context that created this
573+
async event.
575574

576575
Example usage:
577576

0 commit comments

Comments
 (0)