Context is preserved between two runPromise calls
See original GitHub issueRunning the command in sequence preserves the context. I would expect that each call would create a clean context, like is the case with run
Is that normal behavior?
await namespace.runPromise(async () => {
set("foo", "bar");
const foo = get("foo");
console.log("VAELU", foo);
})
await namespace.runPromise(async () => {
const foo = get("foo");
console.log("Value", foo); // Here is prints "bar" instead of undefined
});
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:34
Top Results From Across the Web
Developers - Context is preserved between two runPromise calls -
Running the command in sequence preserves the context. I would expect that each call would create a clean context, like is the case...
Read more >Memory leak in cls-hooked or wrong use? - node.js
There is a function destroy(id) inside cls-hooked/context.js but that it is never called. I tried also ns.bind, ns.runPromise (which does a ns.
Read more >cls-hooked | Yarn - Package Manager
Application-specific namespaces group values local to the set of functions whose calls originate from a callback passed to namespace.run() or namespace.bind() .
Read more >Keeping request context over the function call stack - Medium
The SSENSE ecosystem is composed of multiple applications and services, each of ... Below is an example of a call between two services:....
Read more >NetSuite Applications Suite - Oracle Help Center
Cloud · Cloud Applications · NetSuite. NetSuite Applications Suite. Table of Contents; Search. Contents. Expand AllCollapse All.
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
Just come across this issue, too. Changed to using
runAndReturn
instead, and that seems to have fixed it for me. Should just be a literal swap out since it will be returning the promise of your async methodsI’m dealing with something like this. I have a system that receives HTTP requests and also subscribes to Pubsub topics, it creates a new context for each HTTP request (with
ns.run()
) and every Pubsub message (withns.runAndReturn()
).Each transaction is supposed to generate a new transactionId (UUID), unless it is sent over by headers or in the message metadata, in that case a new context is created with but with the received transactionId, so we can trace the related transactions over our microservices.
The problem is we’re seeing the same transactionId being repeated a lot across thousands of different unrelated requests, and we can only assume it’s an issue with cls-hooked (and not the uuid generation lib).
I don’t know if it’s related to this issue, because I’m not using the
ns.runPromise()
, but it might be… I’m not yet able to consistently reproduce it, and as soon as I can, I’ll post here or create a separate issue.