Context occasionally gets corrupted
See original GitHub issueHello!
Trying to debug a pretty tricky issue. We use this library to thread a distributed traceId down to our logs and shared HTTP library across many many microservices. In rare cases, we’re seeing logs and requests hop from one traceId to another. In essence, this code:
const oldTrace = clsHooked.getNamespace('DEFAULT_NAMESPACE').get('context').traceId;
const res = await httpClient.get(someUrl);
const newTrace = clsHooked.getNamespace('DEFAULT_NAMESPACE').get('context').traceId;
if(oldTrace !== newTrace) {
console.log('~~ TRACE ID MISMATCH: ', oldTrace, newTrace);
process.exit(1);
}
Fails pretty consistently, and I’m trying to figure out why. I’m still grappling with how async_hooks and cls-hooked work in general, but my understanding is that things like older or non-standard promise libraries or custom then
ables (as mentioned in #37) can cause this to happen.
Any advice on tracking down exactly what’s happening?
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (1 by maintainers)
Top Results From Across the Web
Windows 10 right click context box text corrupted
Hi, It seems like the system is running out of resources if the issue sometimes goes away. Can you observe if it's the...
Read more >c# - EntityFramework returns corrupted/swaped data from SQL ...
To fix it, go to the EDMX model, right click to the header of problematic View and choose "Show in model browser". Then...
Read more >occasional EEPROM corruption - possible causes?
I need suggestions for what could possibly be causing the EEPROM in an 18LF2420 to occasionally become corrupted. The important facts:
Read more >D3D11 device context in a separate thread gets corrupted ...
D3D11 device context in a separate thread gets corrupted when CUDA graphics resource mapping is used.
Read more >How to Fix Corrupt Drivers on Windows 10 - MakeUseOf
If your driver is already updated and still corrupted, reinstalling it can sometimes do the trick. Follow the steps below:.
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
Has anyone found a resolution to this? We appear to be experiencing the same issue as described here. Still running some tests to see if I can triage the issue further, but the description sounds exactly like what we see - data that is leaking between requests.
+1 to this issue.
We are currently using cls-hooked with Express. We have it as a middleware and are setting a few request specific values such as a client and tenant ID which are used for routing the connection to the correct database.
We have noticed our service is generating 404’s (as part of validation from database queries) as the connections were being routed to the wrong databases. As part of debugging this issue we wrote some scripts to load the server calling GET’s with valid information but quickly swapping between two different tenants and thus the connections should be routed to different databases.
Within 30 seconds or less, we would get a 404 and upon inspecting the logs, the request would be using the tenant ID from the previous request.
We have not been able to make any inroads on fixing this bug except for the scripts which easily reproduce it. We don’t have any problems in times of low concurrent requests.
We are running Node 12.13.0.