@@ -316,22 +316,19 @@ functions called by `foo`. Outside of `run`, calling `getStore` will return
316
316
317
317
### Troubleshooting: Context loss
318
318
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.
323
321
324
322
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.
326
324
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
328
326
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.
335
332
336
333
## Class: ` AsyncResource `
337
334
0 commit comments