Skip to content

Commit 2d20567

Browse files
committed
ref: Use setup for deno cron
1 parent a726c35 commit 2d20567

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/deno/src/integrations/deno-cron.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { convertIntegrationFnToClass, withMonitor } from '@sentry/core';
1+
import { convertIntegrationFnToClass, getClient, withMonitor } from '@sentry/core';
22
import type { IntegrationFn } from '@sentry/types';
33
import { parseScheduleToString } from './deno-cron-format';
44

@@ -9,10 +9,10 @@ type CronParams = [string, string | Deno.CronSchedule, CronFn | CronOptions, Cro
99

1010
const INTEGRATION_NAME = 'DenoCron';
1111

12-
const denoCronIntegration: IntegrationFn = () => {
12+
const denoCronIntegration = (() => {
1313
return {
1414
name: INTEGRATION_NAME,
15-
setupOnce() {
15+
setup(client) {
1616
// eslint-disable-next-line deprecation/deprecation
1717
if (!Deno.cron) {
1818
// The cron API is not available in this Deno version use --unstable flag!
@@ -35,6 +35,10 @@ const denoCronIntegration: IntegrationFn = () => {
3535
}
3636

3737
async function cronCalled(): Promise<void> {
38+
if (getClient() !== client) {
39+
return;
40+
}
41+
3842
await withMonitor(monitorSlug, async () => fn(), {
3943
schedule: { type: 'crontab', value: parseScheduleToString(schedule) },
4044
// (minutes) so 12 hours - just a very high arbitrary number since we don't know the actual duration of the users cron job
@@ -49,7 +53,7 @@ const denoCronIntegration: IntegrationFn = () => {
4953
});
5054
},
5155
};
52-
};
56+
}) satisfies IntegrationFn;
5357

5458
/** Instruments Deno.cron to automatically capture cron check-ins */
5559
// eslint-disable-next-line deprecation/deprecation

0 commit comments

Comments
 (0)