Skip to content

Commit 7a07df4

Browse files
authored
doc: edit async_context context loss text
Make the text more concise and clear. PR-URL: #41550 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent f8f3d35 commit 7a07df4

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

doc/api/async_context.md

+9-12
Original file line numberDiff line numberDiff line change
@@ -316,22 +316,19 @@ functions called by `foo`. Outside of `run`, calling `getStore` will return
316316

317317
### Troubleshooting: Context loss
318318

319-
In most cases your application or library code should have no issues with
320-
`AsyncLocalStorage`. But in rare cases you may face situations when the
321-
current store is lost in one of the asynchronous operations. In those cases,
322-
consider the following options.
319+
In most cases, `AsyncLocalStorage` works without issues. In rare situations, the
320+
current store is lost in one of the asynchronous operations.
323321

324322
If your code is callback-based, it is enough to promisify it with
325-
[`util.promisify()`][], so it starts working with native promises.
323+
[`util.promisify()`][] so it starts working with native promises.
326324

327-
If you need to keep using callback-based API, or your code assumes
325+
If you need to use a callback-based API or your code assumes
328326
a custom thenable implementation, use the [`AsyncResource`][] class
329-
to associate the asynchronous operation with the correct execution context. To
330-
do so, you will need to identify the function call responsible for the
331-
context loss. You can do that by logging the content of
332-
`asyncLocalStorage.getStore()` after the calls you suspect are responsible for
333-
the loss. When the code logs `undefined`, the last callback called is probably
334-
responsible for the context loss.
327+
to associate the asynchronous operation with the correct execution context.
328+
Find the function call responsible for the context loss by logging the content
329+
of `asyncLocalStorage.getStore()` after the calls you suspect are responsible
330+
for the loss. When the code logs `undefined`, the last callback called is
331+
probably responsible for the context loss.
335332

336333
## Class: `AsyncResource`
337334

0 commit comments

Comments
 (0)