getsentry / getsentry/sentry-dotnet

Startup Crash: Only block Init to flush events if the app crashed on the last run

Open
#1,164 1 comment 0 reactions 0 assignees View on GitHub
.NET Feature
Dominant language
C#
Stars
770
Forks
248
Avg merge
3d 4h
Merged PRs (30d)
49

Description

Currently we block Init to flush envelopes if there's anything on disk. Since the introduction of other envelope item types, we could be blocking `Init` for up to `InitCacheFlushTimeout` to flush out those items that could anyway be flushed asynchronously.

The goal behind `InitCacheFlushTimeout` and blocking init was to ensure crashes that happen right after Sentry is initialized and bring down the app are captured. We need to focus on that goal without the side effect of slowing down app starts for other reasons.

Suggested solution: On unhandled errors we write a marker file to disk such as `crashed-at` with a timestamp in it. This could be done exclusively on the UnhandledException integration and could be written by native integrations such as the iOS SDK for Unity. The SDK will only block to flush if such marker file exists. Additionally we should remove that marker file if we were able to flush the payload successfully before shutting down, which is expected on normal CLR/CoreCLR execution. This is mainly an issue on mobile where the OS often terminates the app if it tries to open a TLS connection (what we noticed during our Android tests on Java and C# unhandled exception handlers).

More context at: https://github.com/getsentry/sentry-unity/issues/286#issuecomment-904825819

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.