Skip to content

Commit fe47a8e

Browse files
committed
fix: use safe wrappers and ignore rule when not needed in next sdk
1 parent a9f105d commit fe47a8e

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

packages/nextjs/src/common/pages-router-instrumentation/wrapApiHandlerWithSentryVercelCrons.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { captureCheckIn } from '@sentry/core';
1+
import { _INTERNAL_safeDateNow, captureCheckIn } from '@sentry/core';
22
import type { NextApiRequest } from 'next';
33
import type { VercelCronsConfig } from '../types';
44

@@ -57,14 +57,14 @@ export function wrapApiHandlerWithSentryVercelCrons<F extends (...args: any[]) =
5757
},
5858
);
5959

60-
const startTime = Date.now() / 1000;
60+
const startTime = _INTERNAL_safeDateNow() / 1000;
6161

6262
const handleErrorCase = (): void => {
6363
captureCheckIn({
6464
checkInId,
6565
monitorSlug,
6666
status: 'error',
67-
duration: Date.now() / 1000 - startTime,
67+
duration: _INTERNAL_safeDateNow() / 1000 - startTime,
6868
});
6969
};
7070

@@ -82,7 +82,7 @@ export function wrapApiHandlerWithSentryVercelCrons<F extends (...args: any[]) =
8282
checkInId,
8383
monitorSlug,
8484
status: 'ok',
85-
duration: Date.now() / 1000 - startTime,
85+
duration: _INTERNAL_safeDateNow() / 1000 - startTime,
8686
});
8787
},
8888
() => {
@@ -98,7 +98,7 @@ export function wrapApiHandlerWithSentryVercelCrons<F extends (...args: any[]) =
9898
checkInId,
9999
monitorSlug,
100100
status: 'ok',
101-
duration: Date.now() / 1000 - startTime,
101+
duration: _INTERNAL_safeDateNow() / 1000 - startTime,
102102
});
103103
return maybePromiseResult;
104104
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @sentry-internal/sdk/no-unsafe-random-apis */
12
// Polyfill for Node.js perf_hooks module in edge runtime
23
// This mirrors the polyfill from packages/vercel-edge/rollup.npm.config.mjs
34
const __sentry__timeOrigin = Date.now();

packages/nextjs/src/config/withSentryConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export function withSentryConfig<C>(nextConfig?: C, sentryBuildOptions: SentryBu
9494
*/
9595
function generateRandomTunnelRoute(): string {
9696
// Generate a random 8-character alphanumeric string
97+
// eslint-disable-next-line @sentry-internal/sdk/no-unsafe-random-apis
9798
const randomString = Math.random().toString(36).substring(2, 10);
9899
return `/${randomString}`;
99100
}

0 commit comments

Comments
 (0)