Skip to content

Commit fe5b5c1

Browse files
committed
Call clearActiveSpanFromScope in all cases
1 parent 9ea77cd commit fe5b5c1

File tree

1 file changed

+3
-3
lines changed
  • packages/core/src/js/tracing

1 file changed

+3
-3
lines changed

packages/core/src/js/tracing/span.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export const startIdleNavigationSpan = (
6161
const activeSpan = getActiveSpan();
6262
const isActiveSpanInteraction = activeSpan && isRootSpan(activeSpan) && isSentryInteractionSpan(activeSpan);
6363

64+
clearActiveSpanFromScope(getCurrentScope());
65+
6466
// Don't cancel user interaction spans when starting from runApplication (app restart/reload).
6567
// This preserves the span context for error capture and replay recording.
6668
if (isActiveSpanInteraction && isAppRestart) {
@@ -69,17 +71,15 @@ export const startIdleNavigationSpan = (
6971
spanToJSON(activeSpan).op
7072
} transaction because navigation is from app restart - preserving error context.`,
7173
);
74+
// Don't end the span - it will timeout naturally and remains available for error/replay processing
7275
} else if (isActiveSpanInteraction) {
7376
debug.log(
7477
`[startIdleNavigationSpan] Canceling ${
7578
spanToJSON(activeSpan).op
7679
} transaction because of a new navigation root span.`,
7780
);
78-
clearActiveSpanFromScope(getCurrentScope());
7981
activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'cancelled' });
8082
activeSpan.end();
81-
} else {
82-
clearActiveSpanFromScope(getCurrentScope());
8383
}
8484

8585
const finalStartSpanOptions = {

0 commit comments

Comments
 (0)