Repository navigation
fix(replay): Advance converted session segment ID from sent segment - #6804
Open
sahuadarsh0 wants to merge 1 commit into
Open
sahuadarsh0 wants to merge 1 commit into
sahuadarsh0 wants to merge 1 commit into
Conversation
sahuadarsh0
requested review from
0xadam-brown and
runningcode
and removed request for
a team
November 29, 2026 09:48
Contributor
PR risk: mediumFor commit Main concerns: reach, data sent to Sentry, public contract. This label is a hint for reviewers, not an approval. |
This branch has not been deployed
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.
📜 Description
Pass the segment ID that
BufferCaptureStrategy.captureReplayactually sent intoonSegmentSent(segmentId, timestamp)and setactiveStrategy.currentSegment = sentSegmentId + 1inReplayIntegration.captureCurrentReplayinstead of incrementing the snapshot copied duringconvert().Also return the last captured buffered segment from
bufferedSegments.capture()soonSegmentSentstill advancescurrentSegmentwhen buffered segments were uploaded and the trailing current segment failed to encode, initialize the convertedSessionCaptureStrategyat segment0so nothing-sent flushes do not start past0, and forwardreplayCacheProviderinBufferCaptureStrategy.convert().💡 Motivation and Context
When an error triggers buffer-to-session conversion while a
configuration_changed,pause, oradd_framerotation task is still queued onreplayExecutor,convert()previously copied an out-of-datecurrentSegmentinto the newSessionCaptureStrategy. Once the queued task ran and mutated the buffer counter beforecapture_replay, incrementing that stale copy caused the next session segment to repeat an already-sent segment ID (or skip one after rotation).💚 How did you test it?
Added deterministic queued-executor tests in
ReplayIntegrationTestcovering:configuration_changedbeforecaptureReplay(reproduced duplicate[0, 1, 1]before the fix; now[0, 1, 2]),add_framerotating out an expired buffered segment beforecaptureReplay(verifies[0, 1, 2]with no skipped ID),pausebeforecaptureReplaywhere the trailing current segment fails to encode after the buffered segment is sent (verifies[0, 1]),plus a
BufferCaptureStrategyTestcheck for the buffered-only callback path.Ran
./gradlew :sentry-android-replay:testReleaseUnitTest --tests "io.sentry.android.replay.ReplayIntegrationTest" --tests "io.sentry.android.replay.capture.*" --tests "io.sentry.android.replay.ReplaySmokeTest" :sentry-android-replay:spotlessCheck :sentry-android-replay:detekt --no-daemon.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps