Skip to content

Native backend: crash envelopes cached while offline are never retried (cache_keep=OFFLINE, http_retry=true) #2193

Closed

Description

@evgen-pervenenko

With the native backend, SENTRY_CACHE_KEEP_OFFLINE and http_retry enabled, a crash that happens while the network is unavailable is written to <database>/cache/, but it is never sent afterwards: neither by the retry queue of the restarted app nor by any later sentry_init. The envelope and its .dmp sidecar stay in the cache until cache_max_age / cache_max_size pruning deletes them.

Regular events captured by the app process while offline are retried correctly. Only envelopes sent by the sentry-crash daemon are affected.

As far as I can tell the cause is this:

  1. The daemon starts its transport with http_retry disabled on purpose and only enables the option after sentry__transport_startup (src/backends/native/sentry_crash_daemon.c, the "Set http_retry after transport startup …" comment). So the daemon's HTTP transport has state->retry == NULL.
  2. When the upload fails, http_send_task falls into the cache_keep branch and writes the envelope with retry_count = -1 (src/transports/sentry_http_transport.c):
    if (!state->retry && state->cache_keep
        && sentry__run_write_cache(state->run, envelope, -1)) {
    This produces a bare <uuid>.envelope filename.
  3. The retry queue skips bare filenames because it treats them as "kept" entries (src/sentry_retry.c):
    if (!sentry__parse_cache_filename(fname, &ts, &count, &uuid)
        || count < 0) {
        continue;
    }

So with KEEP_OFFLINE an offline crash ends up in the "keep" format meant for KEEP_ALWAYS and exhausted retries, and no process ever picks it up. The same code is on master.

When does the problem happen

  • During build
  • During run-time
  • When capturing a hard crash

Environment

  • OS: macOS 26, arm64. The code path is platform-independent, so it should affect Windows and Linux as well (not verified there).
  • Compiler: AppleClang (Xcode 27)
  • CMake version and config: 3.31.8, SENTRY_BACKEND=native, SENTRY_TRANSPORT=curl, SENTRY_BUILD_SHARED_LIBS=OFF, sentry-native 0.17.2

Steps To Reproduce

sentry_options_t *options = sentry_options_new();
sentry_options_set_dsn(options, "<dsn>");
sentry_options_set_database_path(options, "<db>");
sentry_options_set_cache_keep(options, SENTRY_CACHE_KEEP_OFFLINE);
sentry_options_set_http_retry(options, 1);
sentry_options_set_debug(options, 1);
sentry_init(options);

// disconnect the network (or make the DSN host unreachable)
sentry_crash(); // or *(volatile int *)0 = 0;
  1. Run the snippet with the network disconnected and let it crash.
  2. <db>/cache/ now contains <uuid>.envelope and <uuid>.dmp.
  3. Reconnect the network and start the app again with the same options.
  4. The crash is never delivered. The files stay in <db>/cache/ across any number of restarts. Events captured by the app itself while offline are delivered after step 3.

Log output

Cache directory after several online restarts. Crash envelopes from the daemon are bare <uuid> files and are never picked up:

<db>/cache/
  2da2ad1e-bc5f-45c2-4fb3-57afde8beaee.envelope   (crash event, written by sentry-crash)
  c235adee-70b1-4ec3-d905-13d7589567ce.envelope   (crash event, written by sentry-crash, previous day)
  6875b998-56f0-4a5e-1feb-2c590a5c73a3.envelope   (session)
  73335c10-f9ef-4240-c1d7-6c19e490f0ef.envelope   (session)

After renaming one of them to 1791879785000-0-7dadbb84-a051-4d05-81e6-a90b4ce2d3b0.envelope, the next start sent it and removed it, along with the 7dadbb84-….dmp sidecar.

Activity

  1. added
    Bug
    Native
    on Oct 13, 2026
  2. linear-code commented on Oct 13, 2026

    @linear-code
  3. jpnurmi commented on Oct 13, 2026

    @jpnurmi
    Collaborator

    Thanks for bringing it up! Retries are intentionally disabled in the daemon on shutdown, but it should indeed still respect the client-side retry option while caching envelopes that failed to send.

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 13, 2026
  5. added a commit that references this issue on Oct 15, 2026
    f7cb8e2
  6. added a commit that references this issue on Oct 17, 2026
    c549939
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNative

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions