Skip to content

Commit 4e0cb52

Browse files
committed
fix(node-core): passthrough node-cron context
1 parent 64ef553 commit 4e0cb52

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/node-core/src/cron/node-cron.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ export interface NodeCronOptions {
77
}
88

99
export interface NodeCron {
10-
schedule: (cronExpression: string, callback: () => void, options: NodeCronOptions | undefined) => unknown;
10+
schedule: (
11+
cronExpression: string,
12+
callback: (context?: unknown) => void,
13+
options: NodeCronOptions | undefined,
14+
) => unknown;
1115
}
1216

1317
/**
@@ -44,14 +48,14 @@ export function instrumentNodeCron<T>(lib: Partial<NodeCron> & T): T {
4448
throw new Error('Missing "name" for scheduled job. A name is required for Sentry check-in monitoring.');
4549
}
4650

47-
const monitoredCallback = async (): Promise<void> => {
51+
const monitoredCallback = async (context: unknown): Promise<void> => {
4852
return withMonitor(
4953
name,
5054
async () => {
5155
// We have to manually catch here and capture the exception because node-cron swallows errors
5256
// https://github.com/node-cron/node-cron/issues/399
5357
try {
54-
return await callback();
58+
return await callback(context);
5559
} catch (e) {
5660
captureException(e, {
5761
mechanism: {

0 commit comments

Comments
 (0)