Skip to content

Commit 5250cba

Browse files
committed
Account for timeOrigin
1 parent 5202ba6 commit 5250cba

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/nextjs/src/config/polyfills/perf_hooks.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
// Polyfill for Node.js perf_hooks module in edge runtime
22
// This mirrors the polyfill from packages/vercel-edge/rollup.npm.config.mjs
3+
const __sentry__timeOrigin = Date.now();
34

45
// Ensure performance global is available
56
if (typeof globalThis !== 'undefined' && globalThis.performance === undefined) {
67
globalThis.performance = {
7-
timeOrigin: 0,
8+
timeOrigin: __sentry__timeOrigin,
89
now: function () {
9-
return Date.now();
10+
return Date.now() - __sentry__timeOrigin;
1011
},
1112
};
1213
}
1314

1415
// Export the performance object for perf_hooks compatibility
1516
export const performance = globalThis.performance || {
16-
timeOrigin: 0,
17+
timeOrigin: __sentry__timeOrigin,
1718
now: function () {
18-
return Date.now();
19+
return Date.now() - __sentry__timeOrigin;
1920
},
2021
};
2122

0 commit comments

Comments
 (0)