Skip to content

feat: Add option to skip sending previous run envelopes - #2332

Draft
Sebassmaster wants to merge 2 commits into
v1from
feat/option-skip-old-runs
Draft

Sebassmaster wants to merge 2 commits into
v1from
feat/option-skip-old-runs

Conversation

@Sebassmaster

Copy link
Copy Markdown

Adds sentry_options_set_send_previous_run_envelopes(opts, int) (default: enabled). When disabled, sentry_init doesn't send envelopes left over from previous runs; they stay in their run folder and are sent by a later run with the option enabled.

Why

When a send hangs (DNS not answering, unreachable host), sentry_close waits out the shutdown timeout, dumps the queue to disk, and the next sentry_init resends it, which hangs again. The delay repeats every run and the leftovers pile up by one envelope per run. The curl abort from #1585 can't reliably stop this: during connect, curl calls the progress callback ~1/s (vs. 250 ms grace), and during DNS it only returns after the pending getaddrinfo (~10 s). Details and measurements:

What changes

  • Option off: envelopes and run folders are kept; unclosed session.json files are finalized (crashed/abnormal) and written as envelopes into their run folder.
  • on_crashed_last_run still fires, once per crash.
  • Option on: behavior unchanged.
  • With the native and crashpad backends, crash reports are uploaded by the crash handler and aren't affected.

Notes for review

  • With the option off, the run folder is kept, so deleting the .crash marker before the callback is now the only thing preventing on_crashed_last_run from firing again on every start (previously, deleting the run folder also hid a missing marker deletion). send_previous_run_envelopes_disabled_fires_crash_callback_once covers this: with the marker deletion commented out it fails, while the existing on_crashed_last_run still passes.
  • Open questions for the team: cap on kept leftovers (count/age) as a follow-up?

Tests

  • Unit: send_previous_run_envelopes_disabled_{keeps_envelopes,fires_crash_callback_once,marks_one_session_crashed}
  • Integration: test_send_previous_run_envelopes_disabled (inproc, breakpad)

Refs #929
Refs NATIVE-59

@linear-code

linear-code Bot commented Nov 20, 2026

Copy link
Copy Markdown

NATIVE-59

When a send hangs at shutdown, unsent envelopes are dumped to the run folder and resent by the next sentry_init, which hangs again. With sentry_options_set_send_previous_run_envelopes(opts, 0), leftovers stay on disk and are sent by a later run with the option enabled. Crash callbacks and session finalization still run.

Refs #929
@Sebassmaster
Sebassmaster force-pushed the feat/option-skip-old-runs branch from 008793b to 28abef2 Compare November 20, 2026 18:47
@github-actions

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 28abef2

@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.76471% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.79%. Comparing base (87c2032) to head (28abef2).

Additional details and impacted files
@@            Coverage Diff             @@
##               v1    #2332      +/-   ##
==========================================
+ Coverage   75.72%   75.79%   +0.07%     
==========================================
  Files         105      105              
  Lines       30936    30985      +49     
  Branches     5775     5783       +8     
==========================================
+ Hits        23426    23485      +59     
+ Misses       6075     6064      -11     
- Partials     1435     1436       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant