Skip to content

Commit 267898c

Browse files
committed
fix: lint rules
1 parent da8636a commit 267898c

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

packages/core/src/utils/randomSafeContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function safeMathRandom(): number {
3333
}
3434

3535
/**
36-
* Identical to performance.now() but wrapped in withRandomSafeContext
36+
* Identical to Date.now() but wrapped in withRandomSafeContext
3737
* to ensure safe time value generation in certain contexts (e.g., Next.js Cache Components).
3838
*/
3939
export function safeDateNow(): number {

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
}

packages/node-core/src/integrations/context.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ function getCultureContext(): CultureContext | undefined {
204204
*/
205205
export function getAppContext(): AppContext {
206206
const app_memory = process.memoryUsage().rss;
207+
// eslint-disable-next-line @sentry-internal/sdk/no-unsafe-random-apis
207208
const app_start_time = new Date(Date.now() - process.uptime() * 1000).toISOString();
208209
// https://nodejs.org/api/process.html#processavailablememory
209210
const appContext: AppContext = { app_start_time, app_memory };
@@ -236,6 +237,7 @@ export function getDeviceContext(deviceOpt: DeviceContextOptions | true): Device
236237
// Hence, we only set boot time, if we get a valid uptime value.
237238
// @see https://github.com/getsentry/sentry-javascript/issues/5856
238239
if (typeof uptime === 'number') {
240+
// eslint-disable-next-line @sentry-internal/sdk/no-unsafe-random-apis
239241
device.boot_time = new Date(Date.now() - uptime * 1000).toISOString();
240242
}
241243

0 commit comments

Comments
 (0)