Repository navigation
fix(replay): Anchor network span timestamps to the breadcrumb clock - #6959
Merged
Merged
Conversation
The replay network span `start_timestamp`/`end_timestamp` were copied from the xhr hint, which `@sentry/core` fills with `timestampInSeconds()` (performance clock). The breadcrumb itself is stamped with `Date.now()`. The native SDKs select breadcrumbs for a segment by `breadcrumb.timestamp` but emit the rrweb span with the data timestamps, so once the two clocks drift (device sleep, NTP correction) the network span lands minutes away from the video and every other breadcrumb. The product computes the replay start as the minimum of all timestamps, so the timeline was stretched backwards with an empty gap and misplaced touch markers (getsentry/team-replay#548). Keep only the request duration from the hint and anchor it to `breadcrumb.timestamp`, so the span shares the clock the native filter, the video and the other breadcrumbs already use.
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
Plus 4 more 🤖 This preview updates automatically when you update the PR. |
📲 Install BuildsAndroid
|
antonis
approved these changes
Oct 28, 2026
antonis
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Also did a couple of tests runs trying to reproduce the issue and verify the fix:
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.
📢 Type of change
📜 Description
Replay network span
start_timestamp/end_timestampare now anchored tobreadcrumb.timestamp(Date.now()clock). Only the request duration is taken from the xhr hint, whose timestamps come from the performance clock.💡 Motivation and Context
The native SDKs select breadcrumbs for a segment by
breadcrumb.timestampbut emit the rrweb span with the data timestamps. When the two clocks drift (device sleep, NTP correction), the network span lands minutes away from the video and the other breadcrumbs. The product computes the replay start as the minimum of all timestamps, so the timeline is stretched backwards with an empty gap and misplaced touch markers. Fixes getsentry/team-replay#548.💚 How did you test it?
Unit tests in
test/replay/xhrUtils.test.ts, including a case with a 12-minute clock drift.📝 Checklist
sendDefaultPIIis enabled.