@@ -130,24 +130,6 @@ function completeWithRecordedFailure(workflowId: string, executionId: string, er
130130 return buildRecordedJobFailureResult ( { workflowId, executionId, error : failure . message } )
131131}
132132
133- /**
134- * Completes, without alerting, a job whose workspace or workflow was deleted: no owner is left to
135- * act on an alert and no log is left to record the failure in.
136- */
137- function completeWithDeletedScope (
138- requestId : string ,
139- workflowId : string ,
140- executionId : string ,
141- scope : ExecutionScope ,
142- error : unknown
143- ) {
144- logger . info ( `[${ requestId } ] Workflow execution ended: its ${ scope } was deleted` , {
145- workflowId,
146- executionId,
147- } )
148- return completeWithRecordedFailure ( workflowId , executionId , error )
149- }
150-
151133function requireLegacyWorkflowJobString ( value : unknown , field : string ) : string {
152134 if ( typeof value !== 'string' || ! value . trim ( ) ) {
153135 throw new Error ( `Legacy workflow job ${ field } must be a non-empty string` )
@@ -358,11 +340,17 @@ export async function executeWorkflowJob(
358340 executionId,
359341 } )
360342
343+ const completeWithDeletedScope = ( scope : ExecutionScope ) => {
344+ logger . info ( `[${ requestId } ] Workflow execution ended: its ${ scope } was deleted` , {
345+ workflowId,
346+ executionId,
347+ } )
348+ return completeWithRecordedFailure ( workflowId , executionId , error )
349+ }
350+
361351 // Checked before the timeout: a deleted scope leaves nobody to alert about a slow run.
362352 const deletedScope = await resolveDeletedExecutionScope ( error , loggingSession )
363- if ( deletedScope ) {
364- return completeWithDeletedScope ( requestId , workflowId , executionId , deletedScope , error )
365- }
353+ if ( deletedScope ) return completeWithDeletedScope ( deletedScope )
366354
367355 if ( error instanceof ExecutionTimeoutError ) throw error
368356
@@ -388,15 +376,7 @@ export async function executeWorkflowJob(
388376 } )
389377
390378 const scopeDeletedOnCompletion = loggingSession . getDeletedScope ( )
391- if ( scopeDeletedOnCompletion ) {
392- return completeWithDeletedScope (
393- requestId ,
394- workflowId ,
395- executionId ,
396- scopeDeletedOnCompletion ,
397- error
398- )
399- }
379+ if ( scopeDeletedOnCompletion ) return completeWithDeletedScope ( scopeDeletedOnCompletion )
400380
401381 // Complete only when the rejection is durably logged; an unsaved one must still alert.
402382 if (
0 commit comments