Skip to content

Commit

Permalink
πŸ› [RUMF-889] apply correction only for positive drift (#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan authored Apr 30, 2021
1 parent 1c56175 commit cf5109a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/tools/timeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ export function relativeToClocks(relative: RelativeTime) {

function getCorrectedTimeStamp(relativeTime: RelativeTime) {
const correctedOrigin = Date.now() - performance.now()
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
return Math.round(correctedOrigin + relativeTime) as TimeStamp
// apply correction only for positive drift
if (correctedOrigin > getNavigationStart()) {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
return Math.round(correctedOrigin + relativeTime) as TimeStamp
}
return getTimeStamp(relativeTime)
}

export function toServerDuration(duration: Duration): ServerDuration
Expand Down

0 comments on commit cf5109a

Please sign in to comment.