feat(session-replay): upload replay envelope on crash with crashpad, breakpad and inproc backends#1842
Merged
Merged
Conversation
|
jpnurmi
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds
session-replayenvelope upload during crash handling for thecrashpad(Windows/Linux),breakpad, andinprocbackends, extending the native-crash-daemon-only implementation from #1809 to all backends.The delivery model differs from the daemon: since these backends handle the crash in a dying process (or, for
crashpad, hand off to a handler process that only performs multipart minidump uploads), the crash handler consumes the staged<database>/replays/replay-<id>.{mp4,json}files at crash time and persists the resultingreplay_videoenvelope into the run directory via the disk transport.sentry__process_old_runsthen uploads it on the next launch. Because the staged replay files are consumed during crash handling, embedders that clearreplays/beforesentry_init(e.g. sentry-unreal) remain unaffected.Key changes
breakpad / inproc
breakpad_backend_callback/process_ucontext_deferred, flush the pending replay through a run-directory disk transport.replay_idfrom the scope-applied crash event (contexts.replay.replay_id).crashpad (first-chance handler, Windows/Linux)
flush_scope_from_handler, sinceflush_scope_to_eventreleases its reference. The scope-applied event is then used to source the replay flush.src/sentry_session_replay.hsentry__session_replay_flush_pendingitself is unchanged, as it was already transport-agnostic.Tests
REPLAY_ID,stage_replay(), andis_replay_envelope()into shared test helpers (tests/__init__.py).assert_replay_envelope()(tests/assertions.py).test_native_replay_orphan_not_flushed, which incorrectly passed anEnvelopewhere raw bytes were expected, making its no-replay assertion vacuously true.Testing
Added
test_crash_replay_envelope_http(parameterized over inproc and breakpad):replay_videoenvelope.Added
test_crashpad_replay_envelope:replay_videoenvelope upload.SetFirstChanceExceptionHandler).Existing native-daemon tests (
test_native_replay_envelope,test_native_replay_orphan_not_flushed) continue to pass unchanged using the refactored helpers.Verified locally on Windows (MSVC).
Related items
Known limitations
#skip-changelog