Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/node-core/src/cron/node-cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export interface NodeCronOptions {
}

export interface NodeCron {
schedule: (cronExpression: string, callback: () => void, options: NodeCronOptions | undefined) => unknown;
schedule: (
cronExpression: string,
callback: (context?: unknown) => void,
options: NodeCronOptions | undefined,
) => unknown;
}

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

const monitoredCallback = async (): Promise<void> => {
const monitoredCallback = async (...args: Parameters<typeof callback>): Promise<void> => {
return withMonitor(
name,
async () => {
// We have to manually catch here and capture the exception because node-cron swallows errors
// https://github.com/node-cron/node-cron/issues/399
try {
return await callback();
return await callback(...args);
} catch (e) {
captureException(e, {
mechanism: {
Expand Down
Loading