Skip to content

workflow: fail runs on hook conflicts - #327

Merged
fantix merged 3 commits into
mainfrom
fantix/hook-conflict-replay
Aug 27, 2026
Merged

workflow: fail runs on hook conflicts#327
fantix merged 3 commits into
mainfrom
fantix/hook-conflict-replay

Conversation

@fantix

@fantix fantix commented Aug 25, 2026

Copy link
Copy Markdown
Member

This PR fixes a bug that, await UserHook.wait(token=SAME_TOKEN) may hang forever under a race condition.

When two active runs claimed the same token, the World correctly persisted a hook_conflict event for the loser, but the Python handler ignored the event returned from hook_created and acknowledged the queue delivery. Nothing then woke the run to pass that conflict back to the workflow.

The handler now performs another replay pass inside the same delivery, after receiving the hook_conflict from the world, to fail the run. BaseHook.wait() may now raise a newly-added vercel.workflow.HookConflictError (new public API), carrying the conflicting token and an optional conflicting_run_id


Summary

  • Detect hook conflict events returned from hook creation and cold-replay the workflow immediately.
  • Add a public HookConflictError with Python/TypeScript-compatible serialization.
  • Cover conflict liveness, pending waits, typed causes, and non-conflicting registration behavior.

@fantix
fantix force-pushed the fantix/hook-conflict-replay branch from 6065d0c to 3679374 Compare August 26, 2026 18:40
@fantix
fantix force-pushed the fantix/hook-conflict-replay branch from 3679374 to 1ae5cca Compare August 26, 2026 21:55
Base automatically changed from fantix/serialized-errors to main August 27, 2026 01:05
Replay hook conflict events immediately so losing runs do not remain running indefinitely. Add a typed HookConflictError that survives event serialization across Python and TypeScript.
@fantix
fantix force-pushed the fantix/hook-conflict-replay branch from 1ae5cca to 4889d1f Compare August 27, 2026 01:05
@fantix
fantix marked this pull request as ready for review August 27, 2026 01:41
@fantix
fantix requested a review from msullivan August 27, 2026 01:42

@msullivan msullivan 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.

Looks good!

Comment thread src/vercel-workflow/vercel/workflow/_internal/runtime.py Outdated
@fantix
fantix merged commit b16146c into main Aug 27, 2026
14 checks passed
@fantix
fantix deleted the fantix/hook-conflict-replay branch August 27, 2026 18:44
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.

2 participants