AsyncLocalStorage support
See original GitHub issuehttps://nodejs.org/api/async_hooks.html#async_hooks_class_asynclocalstorage
we should run every request in it so that errors can be traced to the original req/res even if they were called in a different event loop. this will also allow us to not pass req/res/ctx to track sources of errors.
the store
would be ctx
const ctx = app.asyncLocalStorage.getStore()
if (ctx) // ...
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:5 (1 by maintainers)
Top Results From Across the Web
AsyncLocalStorage for Easy Context Passing in Node.js | Trabe
AsyncLocalStorage is a new experimental feature included in the async_hooks package that allows us to store data in asynchronous contexts just like we...
Read more >Async hooks | Node.js v19.3.0 Documentation
AsyncLocalStorage tracks async context; process.getActiveResourcesInfo() tracks active resources. The node:async_hooks module provides an API to track ...
Read more >Node.js 14 & AsyncLocalStorage: Share a context between ...
AsyncLocalStorage is used to share data between asynchronous calls. ... is the function receiving a request and calling a service.
Read more >What's Async Local Storage in Node.js v14? - freeCodeCamp
Introducing Async Local Storage – Storage for asynchronous tasks. Consider a web server like Apache running PHP for hosting a website. When PHP ......
Read more >async-local-storage - npm
async-local-storage ... I want something like thread-local storage in threaded programming and async_hooks is usable in node.js 8.0 , so there is ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can always create a middleware that wraps the next middleware in async storage run. There’s no need to build this into koa core and force everyone to use this functionality
I agree, with @dmitriiivashko and @hauau. @jonathanong, have you created a custom middleware as suggested? If so, can this issue be closed?