You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Finished idle spans retain their final timeout callback #26936
startIdleSpan schedules a final timeout so an unfinished span has a hard deadline. When a span ends before that deadline, onIdleSpanEnded sets _finished and runs its cleanup hooks. The final timeout handle is discarded when the timer is scheduled, so the cleanup cannot cancel it.
The pending callback keeps the finished span and its captured state reachable until the timer fires. By then, _finished makes the callback a no-op. With frequent navigation, several generations of finished spans can stay in memory at once. The React Native navigation integration’s ten-minute deadline makes that retention window especially visible. Sentry core source
Hypothetical scenario
Imagine a user switching repeatedly between screens in an app with navigation tracing enabled.
Each navigation span finishes through its normal idle path.
If you inspected the timer queue after the app settled, each finished span’s final callback would still be scheduled until its original deadline.
Proposed fix
Save the final timeout handle and clear it in onIdleSpanEnded. An unfinished span keeps its existing deadline and still ends with deadline_exceeded if the timer fires.
let _idleTimeoutID: ReturnType<typeof setTimeout> | undefined;
let _childSpanTimeoutID: ReturnType<typeof setTimeout> | undefined;
+ let _finalTimeoutID: ReturnType<typeof setTimeout> | undefined;
function onIdleSpanEnded(endTimestamp: number): void {
_finished = true;
+ clearTimeout(_finalTimeoutID);+ _finalTimeoutID = undefined;
activities.clear();
- setTimeout(() => {+ _finalTimeoutID = setTimeout(() => {
if (!_finished) {
Activity
linear-code commentedon Nov 26, 2026
JS-4168