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.

Context occasionally gets corrupted

See original GitHub issue

Hello!

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 thenables (as mentioned in #37) can cause this to happen.

Any advice on tracking down exactly what’s happening?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
kjhangianicommented, Apr 23, 2022

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.

1reaction
william00179commented, Jan 22, 2020

+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.

Read more comments on GitHub >

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

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