@@ -887,7 +887,8 @@ describe("cron service timer regressions", () => {
887887 } ) ;
888888 await runnerStarted . promise ;
889889
890- const runId = `cron:no-timeout-cancel:${ scheduledAt } ` ;
890+ const claimedAt = scheduledAt + 1 ;
891+ const runId = `cron:no-timeout-cancel:${ claimedAt } ` ;
891892 const task = listTaskRecords ( ) . find (
892893 ( entry ) => entry . runtime === "cron" && entry . runId === runId ,
893894 ) ;
@@ -1072,7 +1073,7 @@ describe("cron service timer regressions", () => {
10721073
10731074 const timerPromise = onTimer ( state ) ;
10741075 const observedAbortSignal = await runnerStarted . promise ;
1075- const runId = `cron:cancel-before-timeout:${ scheduledAt } ` ;
1076+ const runId = `cron:cancel-before-timeout:${ scheduledAt + 1 } ` ;
10761077 let timerSettled = false ;
10771078 void timerPromise . then ( ( ) => {
10781079 timerSettled = true ;
@@ -1150,7 +1151,7 @@ describe("cron service timer regressions", () => {
11501151 now += Math . ceil ( FAST_TIMEOUT_SECONDS * 1_000 ) + 10 ;
11511152 await cleanupStarted . promise ;
11521153
1153- const runId = `cron:late-cancel-after-timeout:${ scheduledAt } ` ;
1154+ const runId = `cron:late-cancel-after-timeout:${ scheduledAt + 1 } ` ;
11541155 const task = listTaskRecords ( ) . find (
11551156 ( entry ) => entry . runtime === "cron" && entry . runId === runId ,
11561157 ) ;
@@ -1687,7 +1688,7 @@ describe("cron service timer regressions", () => {
16871688 } ) ;
16881689
16891690 const timerPromise = onTimer ( state ) ;
1690- const runId = `cron:main-session-cancel-boundary:${ scheduledAt } ` ;
1691+ const runId = `cron:main-session-cancel-boundary:${ scheduledAt + 1 } ` ;
16911692 for (
16921693 let attempt = 0 ;
16931694 attempt < 10 && runHeartbeatOnce . mock . calls . length === 0 ;
@@ -1723,7 +1724,7 @@ describe("cron service timer regressions", () => {
17231724 await vi . advanceTimersByTimeAsync ( 0 ) ;
17241725 await timerPromise ;
17251726
1726- const expectedSessionKey = `agent:main:cron:main-session-cancel-boundary:run:${ scheduledAt } ` ;
1727+ const expectedSessionKey = `agent:main:cron:main-session-cancel-boundary:run:${ scheduledAt + 1 } ` ;
17271728 expect ( enqueueSystemEvent ) . toHaveBeenCalledWith (
17281729 "queued downstream work" ,
17291730 expect . objectContaining ( {
@@ -1888,7 +1889,7 @@ describe("cron service timer regressions", () => {
18881889 const persisted = await loadCronStore ( store . storePath ) ;
18891890 const persistedJob = persisted . jobs . find ( ( job ) => job . id === cronJob . id ) ;
18901891 expect ( persistedJob ?. state . lastStatus ) . not . toBe ( "ok" ) ;
1891- expect ( persistedJob ?. state . runningAtMs ) . toBe ( scheduledAt ) ;
1892+ expect ( persistedJob ?. state . runningAtMs ) . toBe ( scheduledAt + 1 ) ;
18921893 } ) ;
18931894
18941895 it ( "persists the due-job start timestamp before creating the cron task run" , async ( ) => {
@@ -2303,11 +2304,11 @@ describe("cron service timer regressions", () => {
23032304 . filter ( ( evt ) => evt . action === "started" )
23042305 . map ( ( evt ) => evt . runAtMs ) ;
23052306
2306- expect ( firstDone ?. state . lastRunAtMs ) . toBe ( dueAt ) ;
2307- expect ( firstDone ?. state . lastDurationMs ) . toBe ( 50 ) ;
2307+ expect ( firstDone ?. state . lastRunAtMs ) . toBe ( dueAt + 1 ) ;
2308+ expect ( firstDone ?. state . lastDurationMs ) . toBe ( 49 ) ;
23082309 expect ( secondDone ?. state . lastRunAtMs ) . toBe ( dueAt + 50 ) ;
23092310 expect ( secondDone ?. state . lastDurationMs ) . toBe ( 20 ) ;
2310- expect ( startedAtEvents ) . toEqual ( [ dueAt , dueAt + 50 ] ) ;
2311+ expect ( startedAtEvents ) . toEqual ( [ dueAt + 1 , dueAt + 50 ] ) ;
23112312 } ) ;
23122313
23132314 it ( "honors cron maxConcurrentRuns for due jobs" , async ( ) => {
@@ -2730,7 +2731,7 @@ describe("cron service timer regressions", () => {
27302731 const persistedReplacementClaimedJob = persisted . jobs . find (
27312732 ( entry ) => entry . id === replacementClaimedJob . id ,
27322733 ) ;
2733- expect ( persistedJob ?. state . runningAtMs ) . toBe ( scheduledAt ) ;
2734+ expect ( persistedJob ?. state . runningAtMs ) . toBe ( scheduledAt + 1 ) ;
27342735 expect ( persistedJob ?. state . lastStatus ) . toBeUndefined ( ) ;
27352736 expect ( persistedUnstartedJob ?. state . runningAtMs ) . toBeUndefined ( ) ;
27362737 expect ( persistedUnstartedJob ?. state . lastStatus ) . toBeUndefined ( ) ;
0 commit comments