@@ -86,7 +86,7 @@ if (!humanInTheLoopLogger) {
8686}
8787
8888interface PauseResumeManagerInternals {
89- markResumeFailed : ( ...args : unknown [ ] ) => Promise < boolean >
89+ markResumeFailed : ( ...args : unknown [ ] ) => Promise < FailedResumeOutcome | undefined >
9090 runResumeExecution : ( ...args : unknown [ ] ) => Promise < unknown >
9191}
9292
@@ -263,24 +263,24 @@ describe('what a failed resume did to its paused execution', () => {
263263 )
264264
265265 it . each ( [
266- { logStatus : 'running' , pauseStatus : 'paused' , executionFailed : true } ,
267- { logStatus : 'cancelled' , pauseStatus : 'paused' , executionFailed : false } ,
268- { logStatus : 'running' , pauseStatus : 'cancelling' , executionFailed : false } ,
269- { logStatus : 'failed' , pauseStatus : 'paused' , executionFailed : true } ,
270- { logStatus : 'completed' , pauseStatus : 'paused' , executionFailed : false } ,
266+ { logStatus : 'running' , pauseStatus : 'paused' , outcome : 'execution_failed' } ,
267+ { logStatus : 'cancelled' , pauseStatus : 'paused' , outcome : undefined } ,
268+ { logStatus : 'running' , pauseStatus : 'cancelling' , outcome : undefined } ,
269+ { logStatus : 'failed' , pauseStatus : 'paused' , outcome : 'execution_failed' } ,
270+ { logStatus : 'completed' , pauseStatus : 'paused' , outcome : 'execution_completed' } ,
271271 ] ) (
272- 'reports the execution failed: $executionFailed for a $logStatus log and $pauseStatus pause' ,
273- async ( { logStatus, pauseStatus, executionFailed } ) => {
272+ 'reports $outcome for a $logStatus log and $pauseStatus pause' ,
273+ async ( { logStatus, pauseStatus, outcome } ) => {
274274 queueTableRows ( workflowExecutionLogs , [ { status : logStatus } ] )
275275 queueTableRows ( pausedExecutions , [ { status : pauseStatus } ] )
276276 const managerInternals = PauseResumeManager as unknown as PauseResumeManagerInternals
277277
278- await expect ( managerInternals . markResumeFailed ( attemptArgs ) ) . resolves . toBe ( executionFailed )
278+ await expect ( managerInternals . markResumeFailed ( attemptArgs ) ) . resolves . toBe ( outcome )
279279 }
280280 )
281281
282282 it . each ( [
283- { logStatus : 'completed' , updated : [ resumeQueue ] } ,
283+ { logStatus : 'completed' , updated : [ resumeQueue , pausedExecutions ] } ,
284284 { logStatus : 'failed' , updated : [ resumeQueue , pausedExecutions ] } ,
285285 { logStatus : 'running' , updated : [ resumeQueue , pausedExecutions , workflowExecutionLogs ] } ,
286286 ] ) (
@@ -348,7 +348,7 @@ describe('what a failed resume did to its paused execution', () => {
348348 snapshotSeed : options . snapshotSeed ,
349349 metadata : { executionId : 'parent-execution-1' , duration : 1 , startTime : 'start' } ,
350350 } ) ,
351- vi . spyOn ( managerInternals , 'markResumeFailed' ) . mockResolvedValueOnce ( true ) ,
351+ vi . spyOn ( managerInternals , 'markResumeFailed' ) . mockResolvedValueOnce ( 'execution_failed' ) ,
352352 vi . spyOn ( LoggingSession , 'markExecutionAsFailed' ) . mockResolvedValueOnce ( ) ,
353353 vi . spyOn ( PauseResumeManager , 'processQueuedResumes' ) . mockResolvedValueOnce ( )
354354 )
@@ -390,13 +390,14 @@ describe('what a failed resume did to its paused execution', () => {
390390 const rawError = new Error ( 'Block failed' )
391391 const spies : { mockRestore : ( ) => void } [ ] = [ ]
392392
393- function failRun ( options : { executionFailed : boolean ; queuedResumesError ?: Error } ) {
393+ function failRun ( options : {
394+ outcome : FailedResumeOutcome | undefined
395+ queuedResumesError ?: Error
396+ } ) {
394397 const managerInternals = PauseResumeManager as unknown as PauseResumeManagerInternals
395398 spies . push (
396399 vi . spyOn ( managerInternals , 'runResumeExecution' ) . mockRejectedValueOnce ( rawError ) ,
397- vi
398- . spyOn ( managerInternals , 'markResumeFailed' )
399- . mockResolvedValueOnce ( options . executionFailed ) ,
400+ vi . spyOn ( managerInternals , 'markResumeFailed' ) . mockResolvedValueOnce ( options . outcome ) ,
400401 options . queuedResumesError
401402 ? vi
402403 . spyOn ( PauseResumeManager , 'processQueuedResumes' )
@@ -410,12 +411,13 @@ describe('what a failed resume did to its paused execution', () => {
410411 } )
411412
412413 it . each ( [
413- { executionFailed : true , reported : [ 'execution_failed' ] } ,
414- { executionFailed : false , reported : [ ] } ,
414+ { outcome : 'execution_failed' as const , reported : [ 'execution_failed' ] } ,
415+ { outcome : 'execution_completed' as const , reported : [ 'execution_completed' ] } ,
416+ { outcome : undefined , reported : [ ] } ,
415417 ] ) (
416- 'reports $reported when it failed the execution: $executionFailed ' ,
417- async ( { executionFailed , reported } ) => {
418- failRun ( { executionFailed } )
418+ 'reports $reported when the attempt left the execution $outcome ' ,
419+ async ( { outcome , reported } ) => {
420+ failRun ( { outcome } )
419421 const { outcomes, args } = argsReportingOutcomes ( )
420422
421423 await expect ( PauseResumeManager . startResumeExecution ( args ) ) . rejects . toBe ( rawError )
@@ -424,7 +426,7 @@ describe('what a failed resume did to its paused execution', () => {
424426 )
425427
426428 it ( 'reports the outcome before draining queued resumes, which may throw' , async ( ) => {
427- failRun ( { executionFailed : true , queuedResumesError : new Error ( 'queue drain failed' ) } )
429+ failRun ( { outcome : 'execution_failed' , queuedResumesError : new Error ( 'queue drain failed' ) } )
428430 const { outcomes, args } = argsReportingOutcomes ( )
429431
430432 await expect ( PauseResumeManager . startResumeExecution ( args ) ) . rejects . toThrow (
@@ -434,7 +436,7 @@ describe('what a failed resume did to its paused execution', () => {
434436 } )
435437
436438 it ( 'rethrows the run failure when the outcome handler fails' , async ( ) => {
437- failRun ( { executionFailed : true } )
439+ failRun ( { outcome : 'execution_failed' } )
438440 const { args } = argsReportingOutcomes ( async ( ) => {
439441 throw new Error ( 'Database unavailable' )
440442 } )
0 commit comments