Skip to content

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

@bruno-garcia

Description

@bruno-garcia

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: getsentry/sentry-unity#286 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureNew feature or request

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions