@@ -179,6 +179,7 @@ async function scheduleCronJobs(
179179 * performs backfilling on any crontab tasks that need it.
180180 */
181181async function registerAndBackfillItems (
182+ ctx : CompiledSharedOptions ,
182183 { pgPool, events, cron } : { pgPool : Pool ; events : WorkerEvents ; cron : Cron } ,
183184 escapedWorkerSchema : string ,
184185 parsedCronItems : ParsedCronItem [ ] ,
@@ -261,6 +262,7 @@ async function registerAndBackfillItems(
261262 // At this time it's not expected that backfilling will be sufficiently
262263 // expensive to justify optimising this further.
263264 events . emit ( "cron:backfill" , {
265+ ctx,
264266 cron,
265267 itemsToBackfill,
266268 timestamp : ts ,
@@ -338,19 +340,21 @@ export const runCron = (
338340 }
339341
340342 const start = new Date ( ) ;
341- events . emit ( "cron:starting" , { cron, start } ) ;
343+ const ctx = compiledSharedOptions ;
344+ events . emit ( "cron:starting" , { ctx, cron, start } ) ;
342345
343346 // We must backfill BEFORE scheduling any new jobs otherwise backfill won't
344347 // work due to known_crontabs.last_execution having been updated.
345348 await registerAndBackfillItems (
349+ ctx ,
346350 { pgPool, events, cron } ,
347351 escapedWorkerSchema ,
348352 parsedCronItems ,
349353 new Date ( + start ) ,
350354 useNodeTime ,
351355 ) ;
352356
353- events . emit ( "cron:started" , { cron, start } ) ;
357+ events . emit ( "cron:started" , { ctx , cron, start } ) ;
354358
355359 if ( ! cron . _active ) {
356360 return stop ( ) ;
@@ -411,6 +415,7 @@ export const runCron = (
411415 } ,
412416 ) ;
413417 events . emit ( "cron:prematureTimer" , {
418+ ctx,
414419 cron,
415420 currentTimestamp,
416421 expectedTimestamp,
@@ -427,6 +432,7 @@ export const runCron = (
427432 ) } s behind)`,
428433 ) ;
429434 events . emit ( "cron:overdueTimer" , {
435+ ctx,
430436 cron,
431437 currentTimestamp,
432438 expectedTimestamp,
@@ -449,6 +455,7 @@ export const runCron = (
449455 // Finally actually run the jobs.
450456 if ( jobsAndIdentifiers . length ) {
451457 events . emit ( "cron:schedule" , {
458+ ctx,
452459 cron,
453460 timestamp : expectedTimestamp ,
454461 jobsAndIdentifiers,
@@ -461,6 +468,7 @@ export const runCron = (
461468 useNodeTime ,
462469 ) ;
463470 events . emit ( "cron:scheduled" , {
471+ ctx,
464472 cron,
465473 timestamp : expectedTimestamp ,
466474 jobsAndIdentifiers,
0 commit comments