@@ -92,10 +92,10 @@ operation.
92
92
The callbacks ` init() ` /` before() ` /` after() ` /` destroy() ` are called for the
93
93
respective asynchronous event during a resource's lifetime.
94
94
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 .
99
99
100
100
``` js
101
101
const async_hooks = require (' async_hooks' );
@@ -125,7 +125,7 @@ const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
125
125
##### Error Handling
126
126
127
127
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
129
129
all ` uncaughtException ` listeners are removed, thus forcing the process to
130
130
exit. The ` 'exit' ` callbacks will still be called unless the application is run
131
131
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.
173
173
Enable the callbacks for a given ` AsyncHook ` instance. If no callbacks are
174
174
provided enabling is a noop.
175
175
176
- The ` AsyncHook ` instance is by default disabled . If the ` AsyncHook ` instance
176
+ The ` AsyncHook ` instance is disabled by default. If the ` AsyncHook ` instance
177
177
should be enabled immediately after creation, the following pattern can be used.
178
178
179
179
``` js
@@ -196,7 +196,7 @@ For API consistency `disable()` also returns the `AsyncHook` instance.
196
196
197
197
Key events in the lifetime of asynchronous events have been categorized into
198
198
four areas: instantiation, before/after the callback is called, and when the
199
- instance is destructed .
199
+ instance is destroyed .
200
200
201
201
##### ` init(asyncId, type, triggerAsyncId, resource) `
202
202
@@ -283,7 +283,7 @@ The second `TCPWRAP` is the new connection from the client. When a new
283
283
connection is made the ` TCPWrap ` instance is immediately constructed. This
284
284
happens outside of any JavaScript stack (side note: a ` executionAsyncId() ` of ` 0 `
285
285
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
287
287
terms of what caused them to be created, so ` triggerAsyncId ` is given the task of
288
288
propagating what resource is responsible for the new resource's existence.
289
289
@@ -295,8 +295,8 @@ the value of `type`. For instance, for the `GETADDRINFOREQWRAP` resource type,
295
295
` resource ` provides the hostname used when looking up the IP address for the
296
296
hostname in ` net.Server.listen() ` . The API for accessing this information is
297
297
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.
300
300
301
301
In the case of Promises, the ` resource ` object will have ` promise ` property
302
302
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:
385
385
TTYWRAP(6) -> Timeout(4) -> TIMERWRAP(5) -> TickObject(3) -> root(1)
386
386
```
387
387
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
389
389
` console.log() ` being called. This is because binding to a port without a
390
390
hostname is a * synchronous* operation, but to maintain a completely asynchronous
391
391
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
408
408
will typically be called 0 times if the asynchronous operation was cancelled
409
409
or, for example, if no connections are received by a TCP server. Persistent
410
410
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
412
412
it only once.
413
413
414
414
@@ -418,7 +418,7 @@ it only once.
418
418
419
419
Called immediately after the callback specified in ` before ` is completed.
420
420
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
422
422
` after ` will run * after* the ` 'uncaughtException' ` event is emitted or a
423
423
` domain ` 's handler runs.
424
424
@@ -568,10 +568,9 @@ asyncResource.triggerAsyncId();
568
568
569
569
#### ` AsyncResource(type[, triggerAsyncId]) `
570
570
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.
575
574
576
575
Example usage:
577
576
0 commit comments