Skip to content

Commit 49cb5a9

Browse files
chargomeclaude
andcommitted
fix(deno): Use Deno.unrefTimer instead of _INTERNAL_safeUnref for interval
Global setInterval in Deno returns a number at runtime, not NodeJS.Timeout. _INTERNAL_safeUnref is a no-op for numbers (it checks typeof timer === 'object'). Use Deno.unrefTimer directly instead, with a type cast to work around @types/node polluting the global setInterval signature in the monorepo. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a723136 commit 49cb5a9

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

packages/deno/src/integrations/denoRuntimeMetrics.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { _INTERNAL_safeDateNow, _INTERNAL_safeUnref, defineIntegration, metrics } from '@sentry/core';
1+
import { _INTERNAL_safeDateNow, defineIntegration, metrics } from '@sentry/core';
22

33
const INTEGRATION_NAME = 'DenoRuntimeMetrics';
44
const DEFAULT_INTERVAL_MS = 30_000;
@@ -57,7 +57,7 @@ export const denoRuntimeMetricsIntegration = defineIntegration((options: DenoRun
5757
...options.collect,
5858
};
5959

60-
let intervalId: ReturnType<typeof setInterval> | undefined;
60+
let intervalId: number | undefined;
6161
let prevFlushTime: number = 0;
6262

6363
const METRIC_ATTRIBUTES_BYTE = { unit: 'byte', attributes: { 'sentry.origin': 'auto.deno.runtime_metrics' } };
@@ -100,7 +100,10 @@ export const denoRuntimeMetricsIntegration = defineIntegration((options: DenoRun
100100
if (intervalId) {
101101
clearInterval(intervalId);
102102
}
103-
intervalId = _INTERNAL_safeUnref(setInterval(collectMetrics, collectionIntervalMs));
103+
// setInterval in Deno returns a number at runtime (global API, not node:timers).
104+
// @types/node in the monorepo overrides the global type to NodeJS.Timeout, so we cast.
105+
intervalId = setInterval(collectMetrics, collectionIntervalMs) as unknown as number;
106+
Deno.unrefTimer(intervalId);
104107
},
105108

106109
teardown(): void {

0 commit comments

Comments
 (0)