Skip to content

Commit ce62e84

Browse files
authored
ref(core): Strengthen browserPerformanceTimeOrigin reliability check (#18719)
In `browserPerformanceTimeOrigin`, we test how reliable `performance.timeOrigin` (or its predecessor) is by comparing its timestamp against `performance.now() - Date.now()`. If the delta is larger than 1h, we take the fallback rather than `performance.timeOrigin`. This PR now makes the reliability check more strict by decreasing the time window from 1h to just 5 minutes. This _should_ catch time drift more often. Now that we improved the fallback via #18715, I think we can give this a shot.
1 parent 2a2e8cb commit ce62e84

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

packages/core/src/utils/time.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ function getBrowserTimeOrigin(): number | undefined {
9191
return undefined;
9292
}
9393

94-
// TOOD: We should probably set a much tighter threshold here as skew can already happen within just a few minutes.
95-
const threshold = 3_600_000; // 1 hour in milliseconds
94+
const threshold = 300_000; // 5 minutes in milliseconds
9695
const performanceNow = performance.now();
9796
const dateNow = Date.now();
9897

packages/core/test/lib/utils/time.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async function getFreshPerformanceTimeOrigin() {
77
return timeModule.browserPerformanceTimeOrigin();
88
}
99

10-
const RELIABLE_THRESHOLD_MS = 3_600_000;
10+
const RELIABLE_THRESHOLD_MS = 300_000;
1111

1212
describe('browserPerformanceTimeOrigin', () => {
1313
it('returns `performance.timeOrigin` if it is available and reliable', async () => {

0 commit comments

Comments
 (0)