Skip to content

fix(workflows): hold the v2 sync run result until its execution log is finalized - #8935

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/stop-after-e2e-race
Oct 12, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/stop-after-e2e-race

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

A run-from-block call that names a just-finished v2 sync run as its source can fail with NOT_FOUND: No execution state found for source run. CI hit this in e2e (stop-after) (run 38262284889, attempt 1; it passed on rerun), and any v2 API, CLI or MCP caller can hit it the same way.

Cause. After a run finishes, the core writes its log and saved execution state in a background step (execution-core.ts). runSynchronousWorkflow in execute-service.ts returned the completed result without waiting for that step. Run-from-block reads the state from the primary DB, found the log row with no state yet, and returned 404. In the CI log the source run passed at 14:24:52.750 and the CLI failed at 14:24:53.773, while the write was still in flight.

Fix. Await loggingSession.waitForPostExecution() in runSynchronousWorkflow's finally, as the legacy execute route already does ("the sync response is the run's receipt"). It covers completed, failed, cancelled, timed-out and thrown runs, and does nothing after a pause. The wait swallows errors and the background step always settles, so it can't hang the response. This is not a retry.

Trade-off. v2 sync responses now include the time to save the log, the same as the legacy route.

Test plan

  • CI e2e (stop-after) and the v2 execute suites

…s 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.
@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 12, 2026 7:49pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Holds synchronous workflow results until the core's post-execution work finishes.

  • Synchronous workflow results wait for their logs and saved state.

Diagram

sequenceDiagram
  participant Caller
  participant Service as executeWorkflowService
  participant Core as executeWorkflowCore
  participant Log as LoggingSession
  Caller->>Service: Execute synchronously
  Service->>Core: Execute with loggingSession
  Core->>Log: Register finalization promise
  Core-->>Service: Run result or error
  Service->>Log: waitForPostExecution()
  Log-->>Service: Post-execution work settled
  Service-->>Caller: Terminal result
Loading

Reviews (1) · Last reviewed commit: "fix(workflows): hold the v2 sync run res..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit bdbb5b6 into staging Oct 12, 2026
38 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/stop-after-e2e-race branch October 12, 2026 19:49

This branch was previously deployed

1 inactive deployment
Preview — f132892c Deployed Oct 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant