GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: add troubleshooting guide for AsyncLocalStorage · nodejs/node@6ffec50

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • async_hooks.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/async_hooks.md‎

Copy file name to clipboardExpand all lines: doc/api/async_hooks.md
+16Lines changed: 16 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,21 @@ In this example, the store is only available in the callback function and the
10851085
functions called by `foo`. Outside of `run`, calling `getStore` will return
10861086
`undefined`.
10871087

1088+
### Troubleshooting
1089+
1090+
In most cases your application or library code should have no issues with
1091+
`AsyncLocalStorage`. But in rare cases you may face situations when the
1092+
current store is lost in one of asynchronous operations. Then you should
1093+
consider the following options.
1094+
1095+
If your code is callback-based, it is enough to promisify it with
1096+
[`util.promisify()`][], so it starts working with native promises.
1097+
1098+
If you need to keep using callback-based API, or your code assumes
1099+
a custom thenable implementation, you should use [`AsyncResource`][] class
1100+
to associate the asynchronous operation with the correct execution context.
1101+
1102+
[`AsyncResource`]: #async_hooks_class_asyncresource
10881103
[`after` callback]: #async_hooks_after_asyncid
10891104
[`before` callback]: #async_hooks_before_asyncid
10901105
[`destroy` callback]: #async_hooks_destroy_asyncid
@@ -1094,3 +1109,4 @@ functions called by `foo`. Outside of `run`, calling `getStore` will return
10941109
[PromiseHooks]: https://docs.google.com/document/d/1rda3yKGHimKIhg5YeoAmCOtyURgsbTH_qaYR79FELlk/edit
10951110
[`Worker`]: worker_threads.html#worker_threads_class_worker
10961111
[promise execution tracking]: #async_hooks_promise_execution_tracking
1112+
[`util.promisify()`]: util.html#util_util_promisify_original

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.