66import type { Edge } from 'reactflow'
77import { z } from 'zod'
88import { getPersonalAndWorkspaceEnv } from '@/lib/environment/utils'
9+ import { clearExecutionCancellation } from '@/lib/execution/cancellation'
910import { createLogger } from '@/lib/logs/console/logger'
1011import type { LoggingSession } from '@/lib/logs/execution/logging-session'
1112import { buildTraceSpans } from '@/lib/logs/execution/trace-spans/trace-spans'
@@ -375,6 +376,8 @@ export async function executeWorkflowCore(
375376 traceSpans : traceSpans || [ ] ,
376377 } )
377378
379+ await clearExecutionCancellation ( executionId )
380+
378381 logger . info ( `[${ requestId } ] Workflow execution cancelled` , {
379382 duration : result . metadata ?. duration ,
380383 } )
@@ -383,6 +386,8 @@ export async function executeWorkflowCore(
383386 }
384387
385388 if ( result . status === 'paused' ) {
389+ await clearExecutionCancellation ( executionId )
390+
386391 logger . info ( `[${ requestId } ] Workflow execution paused` , {
387392 duration : result . metadata ?. duration ,
388393 } )
@@ -398,6 +403,8 @@ export async function executeWorkflowCore(
398403 workflowInput : processedInput ,
399404 } )
400405
406+ await clearExecutionCancellation ( executionId )
407+
401408 logger . info ( `[${ requestId } ] Workflow execution completed` , {
402409 success : result . success ,
403410 duration : result . metadata ?. duration ,
@@ -407,7 +414,6 @@ export async function executeWorkflowCore(
407414 } catch ( error : any ) {
408415 logger . error ( `[${ requestId } ] Execution failed:` , error )
409416
410- // Extract execution result from error if available
411417 const executionResult = ( error as any ) ?. executionResult
412418 const { traceSpans } = executionResult ? buildTraceSpans ( executionResult ) : { traceSpans : [ ] }
413419
@@ -421,6 +427,8 @@ export async function executeWorkflowCore(
421427 traceSpans,
422428 } )
423429
430+ await clearExecutionCancellation ( executionId )
431+
424432 throw error
425433 }
426434}
0 commit comments