From f132892c22e40dca6cc45cb3ebad487a5187cca2 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 12 Oct 2026 12:39:28 -0700 Subject: [PATCH] fix(workflows): hold the v2 sync run result until its execution log is finalized The v2 sync execute path (executeWorkflowService) returned a completed run while executeWorkflowCore was still writing its log and execution state in the background, so a run-from-block naming that run as its source could read no state and 404. The legacy execute route already awaits waitForPostExecution before responding; do the same here. --- apps/sim/lib/workflows/executor/execute-service.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/sim/lib/workflows/executor/execute-service.ts b/apps/sim/lib/workflows/executor/execute-service.ts index 1bdbd1ebb9e..069f0938de1 100644 --- a/apps/sim/lib/workflows/executor/execute-service.ts +++ b/apps/sim/lib/workflows/executor/execute-service.ts @@ -899,6 +899,12 @@ export async function executeWorkflowService( } finally { abortSignal?.removeEventListener('abort', abortFromRequest) timeoutController.cleanup() + /** + * The sync result is the run's receipt: callers read its log, state, and cost as + * soon as it lands (a run-from-block names it as its source run). The core + * finalizes those in the background, so hold the result until they are durable. + */ + await loggingSession.waitForPostExecution() } }