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

Function get

packages/node-core/src/cron/cron.ts:120–165  ·  view source on GitHub ↗
(target, prop: keyof CronJobConstructor)

Source from the content-addressed store, hash-verified

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) => {
123 const { cronTime, onTick, timeZone } = param;
124
125 if (typeof cronTime !== 'string') {
126 throw new Error(ERROR_TEXT);
127 }
128
129 if (jobScheduled) {
130 throw new Error(`A job named '${monitorSlug}' has already been scheduled`);
131 }
132
133 jobScheduled = true;
134
135 const cronString = replaceCronNames(cronTime);
136
137 param.onTick = async (context: unknown, onComplete?: unknown) => {
138 return withMonitor(
139 monitorSlug,
140 async () => {
141 try {
142 await onTick(context, onComplete);
143 } catch (e) {
144 captureException(e, {
145 mechanism: {
146 handled: false,
147 type: 'auto.function.cron.instrumentCron',
148 },
149 });
150 throw e;
151 }
152 },
153 {
154 schedule: { type: 'crontab', value: cronString },
155 timezone: timeZone || undefined,
156 },
157 );
158 };
159
160 return target.from(param);
161 };
162 } else {
163 return target[prop];
164 }
165 },
166 });
167}

Callers

nothing calls this directly

Calls 4

replaceCronNamesFunction · 0.90
withMonitorFunction · 0.90
captureExceptionFunction · 0.90
fromMethod · 0.45

Tested by

no test coverage detected