Skip to content

Commit ad1ec1e

Browse files
committed
ref: fix deno-cron to register client in setup
1 parent b28867a commit ad1ec1e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

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

55
type CronOptions = { backoffSchedule?: number[]; signal?: AbortSignal };
@@ -9,10 +9,12 @@ type CronParams = [string, string | Deno.CronSchedule, CronFn | CronOptions, Cro
99

1010
const INTEGRATION_NAME = 'DenoCron';
1111

12+
const SETUP_CLIENTS: Client[] = [];
13+
1214
const denoCronIntegration = (() => {
1315
return {
1416
name: INTEGRATION_NAME,
15-
setup(client) {
17+
setupOnce() {
1618
// eslint-disable-next-line deprecation/deprecation
1719
if (!Deno.cron) {
1820
// The cron API is not available in this Deno version use --unstable flag!
@@ -35,7 +37,7 @@ const denoCronIntegration = (() => {
3537
}
3638

3739
async function cronCalled(): Promise<void> {
38-
if (getClient() !== client) {
40+
if (SETUP_CLIENTS.includes(getClient())) {
3941
return;
4042
}
4143

@@ -52,6 +54,9 @@ const denoCronIntegration = (() => {
5254
},
5355
});
5456
},
57+
setup(client) {
58+
SETUP_CLIENTS.push(client);
59+
},
5560
};
5661
}) satisfies IntegrationFn;
5762

0 commit comments

Comments
 (0)