You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
events.create with a run_created event inserts the run with onConflictDoNothing(), so when the run already exists the insert returns no row and create resolves with { run: undefined } instead of signalling the conflict. start() asserts on that field and throws Missing 'run' in server response for 'run_created' event — even though the run is healthy and already running.
This is the race start() documents: it fires events.create(run_created) and world.queue() in parallel, and when the worker dequeues first, run_started on the not-yet-existent run takes the resilient start path and creates the run itself. start() already treats EntityConflictError here as benign ("we can safely return", expected in <=1% of cases) — but the Postgres world never gives it one. world-local throws it for this same race and world-vercel surfaces a 409 that maps to it; world-postgres is the only world that resolves silently.
Throwing before the event insert also stops a duplicate run_created landing in the event log.
Observed on a self-hosted Postgres deployment on 3 of 261 runs (~1%, matching the estimate above) of our highest-frequency workflow over 7 days: each affected run has two run_created events and completed normally, while the trigger that started it returned a 500.
How did you test your changes?
Two cases added to packages/world-postgres/test/storage.test.ts (runs › create):
rejects a duplicate run_created with EntityConflictError — the direct conflict.
rejects run_created when resilient start already created the run — reproduces the production race (run_started on a non-existent run → resilient start → late run_created), asserting exactly one run_created remains in the event log.
Both resolve instead of rejecting against the current insert, and pass with the fix.
pnpm --filter @workflow/world-postgres exec vitest run test/storage.test.ts (119 tests)
`events.create` with a `run_created` event inserts the run with
`onConflictDoNothing()`, so a run that already exists resolves with
`{ run: undefined }` rather than signalling the conflict. `start()`
asserts on that field and throws "Missing 'run' in server response for
'run_created' event", even though the run is healthy and already
running.
This is the race `start()` documents: it fires `events.create` and
`world.queue()` in parallel, and when the worker dequeues first,
`run_started` on the not-yet-existent run takes the resilient start
path and creates the run itself. `start()` already treats
`EntityConflictError` as benign, but the Postgres world never gives it
one — world-local throws it, and world-vercel surfaces a 409 that maps
to it.
Throwing before the event insert also stops a duplicate `run_created`
landing in the event log.
Signed-off-by: Joey Hotz <joeyhotz1@gmail.com>
* origin/main: (21 commits)
docs(agents): note lint/format/typecheck are advisory, not blocking (#2886)
Retry transient connection timeouts (#3013)
fix(world-vercel): append caller User-Agent products instead of discarding them (#2998)
[ci] Enable NestJS e2e-vercel-prod and add to docs as "experimental" (#3011)
[ci] Benchmark comment: Best column + best/p75/p99 deltas (drop Avg/P10) (#3005)
docs: fall back to first child page for sidebar folders without an index (#3009)
[nest] Fix NestJS Vercel build output (#2988)
Avoid resolving run data for background steps (#2993)
chore(docs): update @vercel/geistdocs to 1.14.0 (#3002)
fix(docs): add version-switcher fallback redirects for pages missing in one version (#3003)
ci: update opencode to 1.18.4 and switch backport AI model to claude-fable-5 (#3006)
fix(core): batch stream writes via writeMulti (#2995)
perf(core): cache port discovery in step invocations for self-hosted worlds (#2996)
feat(web-shared): Alt+hover span measurement in the new trace viewer (#2985)
fix(world-postgres): throw EntityConflictError on duplicate run_created (#2983)
[ci] Run benchmarks in-deployment to avoid proxy overhead (#2967)
Enable additional perf optimizations when correctness guarantees are met (#2970)
perf(core): prepare replay payloads concurrently (#2980)
Fix dotted tsconfig alias workflow discovery (#2963)
Adjust helper position on trace viewer (#2968)
...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
events.createwith arun_createdevent inserts the run withonConflictDoNothing(), so when the run already exists the insert returns no row andcreateresolves with{ run: undefined }instead of signalling the conflict.start()asserts on that field and throwsMissing 'run' in server response for 'run_created' event— even though the run is healthy and already running.This is the race
start()documents: it firesevents.create(run_created)andworld.queue()in parallel, and when the worker dequeues first,run_startedon the not-yet-existent run takes the resilient start path and creates the run itself.start()already treatsEntityConflictErrorhere as benign ("we can safely return", expected in<=1%of cases) — but the Postgres world never gives it one.world-localthrows it for this same race andworld-vercelsurfaces a 409 that maps to it;world-postgresis the only world that resolves silently.Throwing before the event insert also stops a duplicate
run_createdlanding in the event log.Observed on a self-hosted Postgres deployment on 3 of 261 runs (~1%, matching the estimate above) of our highest-frequency workflow over 7 days: each affected run has two
run_createdevents and completed normally, while the trigger that started it returned a 500.How did you test your changes?
Two cases added to
packages/world-postgres/test/storage.test.ts(runs›create):rejects a duplicate run_created with EntityConflictError— the direct conflict.rejects run_created when resilient start already created the run— reproduces the production race (run_startedon a non-existent run → resilient start → laterun_created), asserting exactly onerun_createdremains in the event log.Both resolve instead of rejecting against the current insert, and pass with the fix.
pnpm --filter @workflow/world-postgres exec vitest run test/storage.test.ts(119 tests)pnpm --filter @workflow/world-postgres typecheckbiome check packages/world-postgres/src/storage.ts packages/world-postgres/test/storage.test.tsPR Checklist - Required to merge
pnpm changesetwas run to create a changelog for this PRgit commit --signoffon your commits)@vercel/workflowin a comment once the PR is ready, and the above checklist is complete