Skip to content

Commit 086725f

Browse files
committed
fix(deno): use Deno.unrefTimer instead of safeUnref for interval
1 parent 27ce885 commit 086725f

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+
intervalId = setInterval(collectMetrics, collectionIntervalMs);
104+
// In Deno, setInterval returns a number, so _INTERNAL_safeUnref is a no-op.
105+
// Use Deno.unrefTimer so the interval doesn't prevent the process from exiting.
106+
Deno.unrefTimer(intervalId);
104107
},
105108

106109
teardown(): void {

0 commit comments

Comments
 (0)