From af75e1c8d71f4e20501396966422fccfb0693e63 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Tue, 3 Mar 2026 06:00:55 +0100 Subject: [PATCH] fix(test): Fix flaky previous session finalization test Use awaitility to wait for the previous session file to be deleted instead of asserting immediately. The PreviousSessionFinalizer runs as a separate task after the test's task in the single-threaded executor, so there is a race between the assertion and the file deletion. Co-Authored-By: Claude --- sentry/src/test/java/io/sentry/SentryTest.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sentry/src/test/java/io/sentry/SentryTest.kt b/sentry/src/test/java/io/sentry/SentryTest.kt index 72febe3566..c3da8c1c12 100644 --- a/sentry/src/test/java/io/sentry/SentryTest.kt +++ b/sentry/src/test/java/io/sentry/SentryTest.kt @@ -964,7 +964,9 @@ class SentryTest { } await.untilTrue(triggered) - assertFalse(previousSessionFile.exists()) + // The PreviousSessionFinalizer runs as a separate task after the test's task in the + // single-threaded executor, so we need to wait for it to delete the file too. + await.until { !previousSessionFile.exists() } } @Test