fix: drop app-start transaction when deadline timer fires doze-delayed#5755
fix: drop app-start transaction when deadline timer fires doze-delayed#5755mvanhorn wants to merge 2 commits into
Conversation
…ions in tests Finish the root span when the deadline timer fires too late so the transaction reads as finished (fixes the device-sleep drop test), enable options.isDebug in the two logger-mock tests so DiagnosticLogger forwards to the mock, and apply spotless formatting. Verified locally: spotlessCheck and the full SentryTracerTest suite pass on JDK 17.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3bc4794. Configure here.
| } | ||
| } | ||
| } | ||
| return; |
There was a problem hiding this comment.
Drop path skips finish cleanup
High Severity
The late-deadline drop path finishes the root and clears the scope, but it never runs the cleanup that normal finish() performs before skipping captureTransaction. That leaves the transaction profiler bound, continuous profiling (TRACE lifecycle) unstopped, and compositePerformanceCollector without stop(), so later transactions can fail to profile for the rest of the process after a Doze-delayed deadline drop.
Reviewed by Cursor Bugbot for commit 3bc4794. Configure here.
|
Fixed the failing checks in 3bc4794: the root span is now finished when the deadline timer fires too late (so the dropped transaction reads as finished), the two logger-mock tests enable options.isDebug so DiagnosticLogger actually forwards to the mock, and the test file is spotless-formatted. Verified locally on JDK 17: spotlessCheck plus the full SentryTracerTest suite pass. |


📜 Description
SentryTracernow records the wall-clock time when the deadline timeout is scheduled and, when the timer fires far later than scheduled (more than 2x the configureddeadlineTimeout), drops the transaction instead of force-finishing it withnow(). The drop follows the existingdropIfNoChildrenpattern infinish(): DEBUG log, clear the scope's transaction, cancel timers, nocaptureTransaction. Timers that fire within the slack behave exactly as before (forceFinish with DEADLINE_EXCEEDED).💡 Motivation and Context
When an Android app cold-starts and is backgrounded before first frame, the
ui.loadtransaction's 30s deadline timer (ajava.util.Timer) is frozen during Doze and fires only hours later when the device wakes.forceFinishthen stamps the root span and all children with the current time, producing app-start transactions spanning hours and skewing user-perceived launch metrics. "Timer fired far later than scheduled" is the exact failure signature, so the check stays in platform-neutral core with no Android API and no public API change.Resolves #5752
💚 How did you test it?
New unit tests in
SentryTracerTest: a deadline timeout that fires within the slack still force-finishes with DEADLINE_EXCEEDED; a simulated late fire (scheduled timestamp shifted beyond 2x deadline) drops the transaction, clears it from the scope, and captures nothing. Ran the sentry module test suite.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps