MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / construct

Function construct

packages/node-core/src/cron/cron.ts:80–119  ·  view source on GitHub ↗
(target, args: ConstructorParameters<CronJobConstructor>)

Source from the content-addressed store, hash-verified

78
79 return new Proxy(lib, {
80 construct(target, args: ConstructorParameters<CronJobConstructor>) {
81 const [cronTime, onTick, onComplete, start, timeZone, ...rest] = args;
82
83 if (typeof cronTime !== 'string') {
84 throw new Error(ERROR_TEXT);
85 }
86
87 if (jobScheduled) {
88 throw new Error(`A job named '${monitorSlug}' has already been scheduled`);
89 }
90
91 jobScheduled = true;
92
93 const cronString = replaceCronNames(cronTime);
94
95 async function monitoredTick(context: unknown, onComplete?: unknown): Promise<void> {
96 return withMonitor(
97 monitorSlug,
98 async () => {
99 try {
100 await onTick(context, onComplete);
101 } catch (e) {
102 captureException(e, {
103 mechanism: {
104 handled: false,
105 type: 'auto.function.cron.instrumentCron',
106 },
107 });
108 throw e;
109 }
110 },
111 {
112 schedule: { type: 'crontab', value: cronString },
113 timezone: timeZone || undefined,
114 },
115 );
116 }
117
118 return new target(cronTime, monitoredTick, onComplete, start, timeZone, ...rest);
119 },
120 get(target, prop: keyof CronJobConstructor) {
121 if (prop === 'from') {
122 return (param: CronJobParams) => {

Callers

nothing calls this directly

Calls 1

replaceCronNamesFunction · 0.90

Tested by

no test coverage detected