Skip to content

Commit 89dfdfe

Browse files
committed
fix scope propagation
1 parent 87e957f commit 89dfdfe

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/tracing-internal/src/browser/browserTracingIntegration.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,23 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio
279279
const sentryTrace = getMetaContent('sentry-trace');
280280
const baggage = getMetaContent('baggage');
281281

282+
// Continue trace updates the _current_ scope, but we want to break out of it again...
283+
// This is a bit hacky, because we want to get the span to use both the correct scope _and_ the correct propagation context
284+
// but afterwards, we want to reset it to avoid this also applying to other spans
282285
const scope = getCurrentScope();
286+
const propagationContextBefore = scope.getPropagationContext();
283287

284-
// Continue trace updates the _current_ scope, but we want to break out of it again...
285288
activeSpan = continueTrace({ sentryTrace, baggage }, () => {
286-
// Ensure we are on the original current scope again
289+
// Ensure we are on the original current scope again, so the span is set as active on it
287290
return withScope(scope, () => {
288291
return _createRouteSpan(client, {
289292
op: 'pageload',
290293
...startSpanOptions,
291294
});
292295
});
293296
});
297+
298+
scope.setPropagationContext(propagationContextBefore);
294299
});
295300

296301
if (options.instrumentPageLoad && WINDOW.location) {

0 commit comments

Comments
 (0)