Skip to content

fix(test): Fix flaky background-foreground replay test#5140

Merged
adinauer merged 1 commit intomainfrom
fix/flaky-lifecycle-watcher-test
Mar 3, 2026
Merged

fix(test): Fix flaky background-foreground replay test#5140
adinauer merged 1 commit intomainfrom
fix/flaky-lifecycle-watcher-test

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Mar 3, 2026

Fix flaky background-foreground replay test in LifecycleWatcherTest.

The test uses sessionIntervalMillis = 2L (2ms), meaning the TimerTask scheduled by the first onBackground() can fire before cancelTask() in the second onForeground() cancels it. When this happens, replayController.stop() gets called from both the first and second timer tasks, causing the Wanted 1 time but was 2 times verification failure.

Increase sessionIntervalMillis to 500ms so the first timer can't race ahead of cancelTask(). The session interval check on the second onForeground() still works correctly since (1 + 500) <= 1 is false.

#skip-changelog

Increase sessionIntervalMillis from 2ms to 500ms so the timer task
from the first onBackground() doesn't fire before cancelTask() in
the second onForeground() can cancel it. With 2ms the timer could
race and call replayController.stop() twice.

Co-Authored-By: Claude <noreply@anthropic.com>
@adinauer adinauer marked this pull request as ready for review March 3, 2026 05:20
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 325.18 ms 383.74 ms 58.56 ms
Size 1.58 MiB 2.29 MiB 723.38 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
91bb874 310.68 ms 359.24 ms 48.56 ms
e59e22a 368.02 ms 432.00 ms 63.98 ms
fc5ccaf 279.11 ms 353.34 ms 74.23 ms
d15471f 315.20 ms 370.22 ms 55.02 ms
d15471f 286.65 ms 314.68 ms 28.03 ms
d15471f 342.08 ms 415.44 ms 73.35 ms
ad8da22 314.38 ms 352.29 ms 37.91 ms
cf708bd 434.73 ms 502.96 ms 68.22 ms
abfcc92 309.54 ms 380.32 ms 70.78 ms
91bb874 314.47 ms 440.00 ms 125.53 ms

App size

Revision Plain With Sentry Diff
91bb874 1.58 MiB 2.13 MiB 559.07 KiB
e59e22a 1.58 MiB 2.20 MiB 635.34 KiB
fc5ccaf 1.58 MiB 2.13 MiB 557.54 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
ad8da22 1.58 MiB 2.29 MiB 719.83 KiB
cf708bd 1.58 MiB 2.11 MiB 539.71 KiB
abfcc92 1.58 MiB 2.13 MiB 557.31 KiB
91bb874 1.58 MiB 2.13 MiB 559.07 KiB

@adinauer adinauer merged commit 7b67c20 into main Mar 3, 2026
71 of 73 checks passed
@adinauer adinauer deleted the fix/flaky-lifecycle-watcher-test branch March 3, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants