Skip to content

feat(crashpad): offline caching#1493

Merged
jpnurmi merged 54 commits intomasterfrom
jpnurmi/feat/crashpad-offline-caching
Feb 11, 2026
Merged

feat(crashpad): offline caching#1493
jpnurmi merged 54 commits intomasterfrom
jpnurmi/feat/crashpad-offline-caching

Conversation

@jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Jan 26, 2026

Converts completed Crashpad reports to Sentry envelopes for offline caching.

  1. After N upload/retry attempts, Crashpad moves reports to <db>/completed/
  2. On the next SDK init, the Crashpad backend iterates over completed reports
    • Each report is converted into a Sentry envelope stored in <db>/cache/
  3. Cache pruning is applied as usual

Depends on:

See also:

JoshuaMoelans and others added 16 commits January 23, 2026 14:21
Before "revert separate caching folder implementation"

#1461
Cast cache_max_age to time_t to avoid implicit signedness conversion
between uint64_t and time_t.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add explicit static_cast<time_t>() for cache_max_age to fix
-Wsign-conversion warning on Windows with clang-cl.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jpnurmi jpnurmi force-pushed the jpnurmi/feat/crashpad-offline-caching branch 4 times, most recently from 4dd6c5e to ff864c4 Compare January 26, 2026 15:27
jpnurmi and others added 3 commits January 27, 2026 13:57
For consistency with time-related operations throughout the codebase.

This adds a time.h dependency to the public header, but it's a
lightweight standard C header available since C89.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
jpnurmi and others added 4 commits February 3, 2026 12:16
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Subtract file size from accumulated_size when a file is pruned (by age
or size). Previously, pruned files' sizes were still counted, causing
subsequent valid files to be incorrectly pruned when both cache_max_age
and cache_max_size were set.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jpnurmi jpnurmi changed the title WIP: feat(crashpad): offline caching feat(crashpad): offline caching Feb 10, 2026
@github-actions
Copy link

github-actions bot commented Feb 10, 2026

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

Generated by 🚫 dangerJS against 2985e08

@jpnurmi jpnurmi marked this pull request as ready for review February 10, 2026 09:32
jpnurmi and others added 2 commits February 10, 2026 11:53
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jpnurmi and others added 2 commits February 10, 2026 12:09
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
jpnurmi and others added 3 commits February 10, 2026 12:26
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ted_reports

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Base automatically changed from jpnurmi/feat/offline-caching to master February 11, 2026 13:13
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

} else if (state->db->DeleteReport(report.uuid)
!= crashpad::CrashReportDatabase::kNoError) {
SENTRY_WARNF("failed to delete \"%s\"", filename.c_str());
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial cache file causes report deletion and data loss

Medium Severity

If sentry_envelope_write_to_path fails but leaves a partial/corrupt file on disk, the next startup will see sentry__path_is_file(out_path) return true, skip rewriting the envelope, and proceed to call DeleteReport — permanently deleting the Crashpad report while only a corrupt envelope remains in cache. The sentry__path_is_file check doesn't validate the file's integrity, so a half-written file from a previous failed attempt is treated as a successfully cached envelope.

Fix in Cursor Fix in Web

Copy link
Collaborator Author

@jpnurmi jpnurmi Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure... To validate the file's integrity, we would either have to store the checksum somewhere or parse the previously written envelope. 🤔

The lack of atomic (temp+rename) file writes could bite in several places in sentry-native. Another scenario: crash during envelope write -> truncated .envelope on disk -> next sentry_init() calls sentry__process_old_runs() -> sentry__envelope_from_path() reads truncated buffer as raw payload -> corrupted envelope sent to Sentry.

@jpnurmi jpnurmi merged commit 9e8a954 into master Feb 11, 2026
46 checks passed
@jpnurmi jpnurmi deleted the jpnurmi/feat/crashpad-offline-caching branch February 11, 2026 18:01
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.

3 participants

Comments