Skip to content

fix(api): prevent stale running patches from clobbering completed executions - #50

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-b33f
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-b33f

Conversation

@cursor

@cursor cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bug and impact

Running a multi-node workflow via POST /api/workflows/[id]/execute returned a completed execution in the HTTP response, but a late fire-and-forget progress patch could overwrite the persisted row with status: running and truncated logs. Refreshing the run history then showed a successful run as still running.

Root cause

WorkflowExecutor.notifyUpdate called updateExecution without awaiting it, and the route inserted the row only after execute() finished. Mid-run patches that were still in flight after the insert wrote status: running over the completed snapshot. Supabase update() does not error when zero rows match, so this was silent.

Fix

  • Insert the running row before execute() so live updates have a target
  • Await a final updateExecution of the terminal snapshot after execute()
  • Constrain progress UPDATEs with .in("status", ["running", "pending"]) so a late running/paused patch cannot match a completed or failed row
  • Throw on insert/update errors instead of ignoring { error }

Validation

  • pnpm exec vitest run tests/lib/execution-store.test.ts (5 passed)
  • pnpm run test:run (240 passed)
  • pnpm exec tsc --noEmit
Open in Web View Automation 

…cutions

Fire-and-forget progress updates from POST /execute could land after the
terminal row was written and overwrite status and logs with a running snapshot.
Insert the running row first, persist the final snapshot after execute(), and
constrain progress UPDATEs to running/pending rows.

Co-authored-by: esadrianno <esadrianno@gmail.com>
@vercel

vercel Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
v0-agent-kit Ready Ready Preview, v0 Aug 13, 2026 11:34am

This branch was successfully deployed

1 active deployment
Preview — 5ed1651f Deployed Aug 13, 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