Repository navigation
fix(opentelemetry): Keep live context link when passing a scope to withScope - #26234
Merged
Merged
Conversation
…thScope `withScope(scope, cb)` replaced the scope's WeakRef context link with the short-lived callback context. Once that context was garbage collected, `getActiveSpan(scope)` returned undefined, so `startInactiveSpan` started new root spans and error events were attributed to the wrong span. This hit every outgoing HTTP response via `bindScopeToEmitter`. Fixes #26217 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
size-limit report 📦Compared: 8447a86 (PR test merge using develop at 7bc0a5d) Against: 7bc0a5d (develop) · base run #65460 ✅ Baseline matches: this diff contains only this PR's changes.
|
Member
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit ae9799e. Configure here.
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 8 not successful, 46 successful. See the run.
Successful checks
|
msonnb
marked this pull request as ready for review
November 10, 2026 12:20
msonnb
requested review from
andreiborza and
isaacs
and removed request for
a team and
stephanie-anderson
November 10, 2026 12:20
andreiborza
approved these changes
Nov 11, 2026
51 tasks done
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: With OpenTelemetry,
withScope(scope, cb)replaced the scope'sWeakRefcontext link withcb's short-lived context. Once that context was garbage collected,getActiveSpan(scope)returnedundefined, so new spans became root spans and errors got the wrongspan_id. This happened on nearly every outgoing HTTP response because ofbindScopeToEmitter. The fix keeps a link that is still alive. That's safe becausewithSetScopebuilds the callback context from the linked one, so both have the same active span.Closes #26217