Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b5104e8

Browse filesBrowse files
TrottBethGriggs
authored andcommitted
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 3084dff commit b5104e8
Copy full SHA for b5104e8

File tree

Expand file treeCollapse file tree

1 file changed

+9
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-12
lines changed
Open diff view settings
Collapse file

‎doc/api/async_context.md‎

Copy file name to clipboardExpand all lines: doc/api/async_context.md
+9-12Lines changed: 9 additions & 12 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.