question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AsyncLocalStorage support

See original GitHub issue

https://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:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dmitriiivashkocommented, Sep 19, 2020

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

1reaction
jkomynocommented, Apr 16, 2021

I agree, with @dmitriiivashko and @hauau. @jonathanong, have you created a custom middleware as suggested? If so, can this issue be closed?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found