Skip to content

Commit 9870761

Browse files
antonisclaude
andcommitted
fix(e2e): Make Android crash flag auto-expire after one crash
The crash flag file was persisting across app launches, causing the app to crash indefinitely. Now the flag auto-deletes when read, allowing: 1. First launch: Enable flag 2. Second launch: Read flag, delete it, then crash 3. Third launch: Start normally and send crash report This solves the chicken-and-egg problem where the app couldn't reach JavaScript to clear the flag because it kept crashing before JS loaded. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 5bf59f4 commit 9870761

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

samples/react-native/android/app/src/main/java/io/sentry/reactnative/sample/MainApplication.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ class MainApplication :
5656
private fun shouldCrashOnStart(): Boolean {
5757
// Check if crash flag file exists (for E2E testing)
5858
val crashFile = getFileStreamPath(".sentry_crash_on_start")
59-
return crashFile.exists()
59+
if (crashFile.exists()) {
60+
// Delete the flag immediately so we only crash once
61+
// This allows the next launch to succeed and send the crash report
62+
crashFile.delete()
63+
return true
64+
}
65+
return false
6066
}
6167
}

samples/react-native/e2e/tests/captureAppStartCrash/captureAppStartCrash.test.android.manual.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,13 @@ appId: io.sentry.reactnative.sample
1818
- tapOn: "Enable Crash on Start"
1919
- stopApp
2020

21-
# Second launch: App will crash on start due to flag file
21+
# Second launch: App crashes on start
22+
# The crash flag auto-deletes when read, so app only crashes once
2223
- launchApp:
2324
clearState: false
2425
stopApp: false
2526

26-
# Third launch: Crash event is sent before crashing again
27+
# Third launch: App starts normally and sends the crash event
2728
- launchApp:
2829
clearState: false
2930
stopApp: false
30-
31-
# Fourth launch: Disable the crash flag so app can run normally
32-
- launchApp:
33-
clearState: false
34-
stopApp: false
35-
36-
# Wait for app to stabilize
37-
- waitForAnimationToEnd:
38-
timeout: 2000
39-
40-
# Scroll down to find the "Disable Crash on Start" button
41-
- scrollUntilVisible:
42-
element: "Disable Crash on Start"
43-
timeout: 10000
44-
direction: DOWN
45-
46-
- tapOn: "Disable Crash on Start"

0 commit comments

Comments
 (0)