sentry-java: Uncaught exceptions (crashes) aren't sent in time
Overview
Typically, crash reporters will persist crash data in the event it doesn’t get sent immediately, e.g. sending crash events the next time a process is run. raven-java doesn’t appear to persist the data anywhere, so uncaught exceptions cannot be reported.
Steps to reproduce
- Add
raven-javato an Android project - Call
Raven.sendExceptioninside Java’s uncaught exception handler* - Raise a
RuntimeException(or other exception) outside of a try/catch block
* For example:
Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
Log.e("An uncaught exception occurred: " + e);
Raven.sendException(e);
}
});
Expected results
Log is emitted immediately, and an event is sent to Sentry the next time the app is run.
Actual results
Log is immediately sent, but the Sentry Event is never sent due to the app being terminated before transmission completes. Is there another way to configure Sentry that I’m missing?
Proposed solution
Store events in the circular FIFO queue prior to transmission. Remove them as they are sent, but in the event of an uncaught exception, serialize the queue to some configured path on disk. When Raven is initialized, it should attempt to restore the queue from data on disk at the configured location.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 31
We now write events to disk first when buffering is enabled (true on Android by default) on
master, release soon.