Repository navigation
fix(android): Don't swallow interrupts while flushing a startup crash - #6568
Open
runningcode wants to merge 2 commits into
Open
runningcode wants to merge 2 commits into
runningcode wants to merge 2 commits into
Conversation
After a startup crash, SendCachedEnvelopeIntegration blocks the thread that calls Sentry.init until the cached envelopes are sent. If that thread was interrupted, future.get() cleared the interrupt and the trailing catch (Throwable) swallowed it, so the caller never saw it. It also logged that cached events will not be sent, although the task keeps sending them. Catch InterruptedException next to the timeout, restore the interrupt and continue in the background. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
📲 Install BuildsAndroid
|
runningcode
marked this pull request as ready for review
November 11, 2026 15:58
runningcode
requested review from
0xadam-brown and
markushi
and removed request for
a team
November 11, 2026 15:58
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
One of the issues with broad catches is that you can ignore the interrupt.
This changes the code so that the calling thread's interrupt isn't ignored.
Concrete summary of the impact from my clanker:
After a crash during the previous app start,
registerblocks the thread that callsSentry.initfor up tostartupCrashFlushTimeoutMillis(5 seconds by default) while the cachedenvelopes are sent. If that thread was interrupted:
future.get()threwInterruptedException, which cleared the thread's interrupt.catch (Throwable)swallowed it, so the code that owns the thread never saw theinterrupt.
sending them.
InterruptedExceptionis now caught next to the existingTimeoutException. It restores theinterrupt and logs that the send continues in the background.
💡 Motivation and Context
Found during the
catch (Throwable)audit (#6564, against9.x.x).It rarely shows up on the Android main thread, which nothing interrupts. It matters when an app
initializes Sentry on a worker thread that gets cancelled, for example by
ExecutorService.shutdownNow(), during that wait.💚 How did you test it?
Added a unit test that interrupts the calling thread before
register, while the startup crashflush is still running. It checks that the interrupt survives and that the cached envelopes are
still sent in the background. The test fails without the fix.
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
🤖 Generated with Claude Code