-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setTimeout callback wrong context on node 10 #1494
Comments
I think the problem is that
If we start the Node 12 uses no queuing via |
Thinking once more about this the proposed change above may result in quite some side effects and even context loss where context is propagated correct now. |
@Flarna Thanks for diging into this issue, do you plan to make a PR to fix this ? Otherwise i'll implement what you suggested |
@vmarchaud I will create a PR after the weekend |
Thanks @Flarna for investing time and effort to debug and create a PR.
I too think it's a dangerous change, but curious if you have some examples of what it can break. |
I have no example but it would be easy to construct one. But such artificial samples are not really of help because in Javascript it's always easy to break half of the world... I have no real world example I could refer to. Main reason why the current PR is only addressing The other part - to pass |
@vmarchaud Yes, that's true. But if there is already a context active then this one is used. The same use case seen from resource point of view would be different. The active resource is |
Co-authored-by: Amir Blum <[email protected]>
Co-authored-by: Amir Blum <[email protected]>
Co-authored-by: Amir Blum <[email protected]>
What version of OpenTelemetry are you using?
v0.11.0
What version of Node are you using?
v10.22.0
The issue is reproducible in nodejs v10.x.x, and does not exists in versions 11 and forward.
What did you do?
What did you expect to see?
Expected
timer 2
span to have it's own trace id and be the root span. Or a least to behave the same astimer 3
which created a new trace as expected.What did you see instead?
timer 2
has the same context astimer 1
(span's parent ismain
, and has the sametraceId
).Output of ConsoleSpanExporter:
Additional context
The above code snippet is just a minimal code to reproduce the issue. It was encountered in a complex setup with multiple plugins, where http module set the a timer with timeout of 0ms, and another part of the code which called a timer with same timeout received the cascading spans as the HTTP children instead of being created under a new trace.
From my short investigation, it looks like node 10 is grouping timers with same duration under the same 'TIMERWRAP', which receives its async context from the first
setTimeout
and then calls following timers from the same wrapper with the wrong context.In the example above,
timer 3
has the correct context since it is create with duration 1001 ms, which get's it's own fresh wrapper internally in node.The text was updated successfully, but these errors were encountered: