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) {
Thanks @logaretm, I was experiencing memory growth on my react-native app and this one was really hard to track down. Even claude with argent profiling missed it 👀
edit: I understand that timers are being cleared at some point but, in our social app where the users are jumping screens really fast this grows fast.
Activity
linear-code commentedon Nov 26, 2026
JS-4168
logaretm commentedon Nov 26, 2026
Thanks for the report, I created a PR for it but it may introduce a behavior change that we need to consider first.
efstathiosntonas commentedon Nov 27, 2026
Thanks @logaretm, I was experiencing memory growth on my react-native app and this one was really hard to track down. Even claude with
argentprofiling missed it 👀edit: I understand that timers are being cleared at some point but, in our social app where the users are jumping screens really fast this grows fast.
github-actions commentedon Nov 27, 2026
A PR closing this issue has just been released 🚀
This issue was referenced by PR #26938, which was included in the 11.20.0 release.