Skip to content

Backport #3139: fix(core): order step-result deliveries against wait/hook deliveries by event-log position - #3173

Open
github-actions[bot] wants to merge 2 commits into
stablefrom
backport/pr-3139-to-stable
Open

Backport #3139: fix(core): order step-result deliveries against wait/hook deliveries by event-log position#3173
github-actions[bot] wants to merge 2 commits into
stablefrom
backport/pr-3139-to-stable

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Automated backport of #3139 to stable (backport job run).

AI recommendation: This is a correctness fix for a production data-loss class bug: step results were delivered outside the delivery-barrier registry, so a memo-warm replay could deliver them ahead of an earlier-in-log wait_completed/hook_received, permanently diverging the ULID allocation and terminating runs with CORRUPTED_EVENT_LOG. I verified the affected code exists on stable: packages/core/src/private.ts there has pendingDeliveryBarriers with DeliveryKind = 'hook' | 'wait', and step.ts resolves step_completed straight from its promiseQueue slot behind a primitive-result memo (stepHydrationCache), i.e. the same latency asymmetry and the same gap. Note for the human resolving the cherry-pick: packages/core/src/workflow/abort-controller.ts does not exist on stable, so that part of the diff (and the abort case in the new coverage test) must be dropped rather than applied.

Merge conflicts were resolved by AI (opencode with anthropic/claude-opus-5). Please review the conflict resolution carefully before merging.

…by event-log position (#3139)

* fix(core): order step-result deliveries against wait/hook deliveries by event-log position

Two production runs on `@workflow/core@5.0.0-beta.36` burned all three
divergence-recovery replays at the same event and terminated with
CORRUPTED_EVENT_LOG:

  wrun_41KYJENABV0GSF5YTE9EETV5DD  (step vs wait)
  wrun_41KYJEE01S0GPC9RWT5MEKVCX8  (step vs hook)

  Replay divergence: step event step_created for step_X belongs to "A",
  but the current step consumer is "B"

`useStep` proxies draw deterministic ULIDs in invocation order, so the
ULID -> stepName allocation is a function of the order in which promise
resolutions are delivered to workflow code. The delivery-barrier registry
pinned that order to event-log position for hook payloads and wait
completions, but step results were delivered straight off the serial
`promiseQueue` — and their latency varies between replays of the SAME
invocation, because the first replay pays full hydration while later
replays memo-hit primitive results in the shared `ReplayPayloadCache`.
A step completion adjacent in the log to a `wait_completed` was therefore
delivered wait-first on a cold replay and step-first on a warm one;
whichever order the invocation that wrote the follow-up `step_created`
events happened to see became law, and every replay computing the other
order diverged permanently.

Step results and step failures now register a 'step' delivery barrier at
their event-log index and resolve from a detached continuation after every
relevant earlier-in-log delivery, mirroring the hook payload path:
hydration stays inside the serial queue slot (which also releases
`pendingDeliveries`), while the barrier wait and the resolve run off the
queue so a queue slot never blocks on a resolution the queue itself drives.
Waits and hook payloads likewise defer behind earlier step results.

Two details are what actually make the ordering hold, and both were found
by testing rather than by reading the code:

The deferral set is captured while CONSUMING the event, not at the start of
the hydration slot. Captured at slot start it is not merely less
deterministic, it is usually empty: an earlier delivery whose own slot runs
first on the serial queue has typically already resolved and deregistered
its barrier before the later slot begins, so the later delivery does not
defer at all. Every event in one drain window is consumed before any slot
runs, so consumption time sees all of them.

A delivery that had to wait then yields a macrotask before resolving. An
earlier delivery being "delivered" only means its `resolve()` ran; the
branch it woke may need arbitrarily many further microtask hops before it
reaches its next `useStep` call (a `for await` over a hook resumes the
generator, settles the promise from `next()`, and only then runs the loop
body). Ordering the `resolve()` calls alone therefore buys a fixed hop or
two of margin and leaves a hop-count race that holds only for the shortest
consumers; yielding a macrotask lets the earlier branch drain completely,
whatever its shape.

One asymmetry is load-bearing: a step result skips any earlier delivery
that will not resolve on its own, i.e. one blocked directly or
transitively on a buffered hook payload no consumer has claimed. Such a
payload is delivered only when the workflow next reads the hook, and
reaching that read commonly requires the step result itself, so gating the
step on it stalls the run until the barrier's idle safety net fires — which
then releases every delivery queued behind that payload at once and loses
the very race the ordering exists to protect. Waits and hooks keep gating
on unclaimed payloads, where waiting for the claim IS the guarantee.

Tests come in two files. `step-delivery-ordering.test.ts` is byte-identical
to the file in the repro-only companion PR #3137 apart from
two `it.fails` markers there (which let a repro-only branch have green CI);
`sed 's/it\.fails(/it(/g' | cmp` verifies it. Each of its five cases
replays one committed log twice through a shared `ReplayPayloadCache`, and
the two warm-replay cases fail on main with the production error text.

`step-delivery-hop-count.test.ts` exists because those five cases cannot
tell "delivered in log order" apart from "resolves a hop or two later than
before". It replays logs a live run legitimately produced — the live
invocation received the two events in separate deliveries, so the first
branch finished long before the second event existed — while the replay
receives both in one drain window, and pads the consumer with a varying
number of extra awaits so hop count is the only variable. It covers step
results against both wait completions and hook payloads, plus step
FAILURES against wait completions, since a rejection decides whether a
`catch` continuation runs and so which ULID the `useStep` there draws. All
18 cases fail on main; of the 12 that predate the macrotask, 9 still fail
with the resolve-ordering-only version of this fix; all 18 pass here.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>

* fix(core): close remaining delivery-barrier ordering gaps

Follow-up on the step-delivery barrier work, addressing three cases the
registry did not yet cover. Each has a regression test in the new
`delivery-barrier-coverage.test.ts` that reproduces the production
`ReplayDivergenceError` when its fix is reverted.

- Step results now defer behind earlier STEP results. The old exclusion
  assumed the serial `promiseQueue` fixes step-vs-step order, which stopped
  holding once a step began resolving from a detached continuation instead
  of its queue slot: two steps consumed in different drain windows can
  disagree on their deferral set, and the earlier one — parked on the
  macrotask yield — gets overtaken.

- `sleep.ts` and `hook.ts` (waiting-consumer path) now capture their
  deferral at event-consumption time, as `step.ts` already does. Reading
  the registry after their queue work misses an earlier step or hook that
  delivered and retired its barrier in the meantime, skipping both the gate
  and the macrotask yield. The buffered hook payload path deliberately
  keeps evaluating at claim time; a consumption-time snapshot there stalls
  the e2e `hookWithSleepWorkflow`.

- Abort deliveries participate in the registry. `_setAborted` fires the
  signal's listeners, which may invoke a step and draw a ULID, so an abort
  is as branch-deciding as any other delivery.

Also memoizes `resolvesOnItsOwn`. The walk is exponential in the number of
live hook/wait barriers, and the registry is not bounded — a fan-out of
`Promise.race([hook, sleep])` branches accumulates one barrier per branch
per kind (49 measured for 24 branches). At 40 barriers a single scan took
92s before, and is instant after.

---------

Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Nathan Rajlich <n@n8.io>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f3f7f81

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@workflow/core Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/vitest Patch
@workflow/web-shared Patch
@workflow/web Patch
workflow Patch
@workflow/world-testing Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch
@workflow/nuxt Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment Jul 29, 2026 12:47am
example-nextjs-workflow-webpack Ready Ready Preview, Comment Jul 29, 2026 12:47am
example-workflow Ready Ready Preview, Comment Jul 29, 2026 12:47am
workbench-astro-workflow Ready Ready Preview, Comment Jul 29, 2026 12:47am
workbench-express-workflow Ready Ready Preview, Comment Jul 29, 2026 12:47am
workbench-fastify-workflow Ready Ready Preview, Comment Jul 29, 2026 12:47am
workbench-hono-workflow Ready Ready Preview, Comment Jul 29, 2026 12:47am
workbench-nestjs-workflow Ready Ready Preview, Comment Jul 29, 2026 12:47am
workbench-nitro-workflow Ready Ready Preview, Comment Jul 29, 2026 12:47am
workbench-nuxt-workflow Ready Ready Preview, Comment Jul 29, 2026 12:47am
workbench-sveltekit-workflow Ready Ready Preview, Comment Jul 29, 2026 12:47am
workbench-tanstack-start-workflow Ready Ready Preview, Comment Jul 29, 2026 12:47am
workbench-vite-workflow Ready Ready Preview, Comment Jul 29, 2026 12:47am
workflow-docs Ready Ready Preview, Comment, Open in v0 Jul 29, 2026 12:47am
workflow-swc-playground Ready Ready Preview, Comment Jul 29, 2026 12:47am
workflow-tarballs Ready Ready Preview, Comment Jul 29, 2026 12:47am
workflow-web Ready Ready Preview, Comment Jul 29, 2026 12:47am

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

🧪 E2E Test Results

Some tests failed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 1077 0 78 1155
✅ 💻 Local Development 1174 0 86 1260
✅ 📦 Local Production 1174 0 86 1260
✅ 🐘 Local Postgres 1174 0 86 1260
✅ 🪟 Windows 105 0 0 105
❌ 🌍 Community Worlds 82 102 9 193
✅ 📋 Other 594 0 36 630
Total 5380 102 381 5863

❌ Failed Tests

🌍 Community Worlds (102 failed)

redis (19 failed):

  • hookWorkflow | wrun_01KYNND9ZDV2SJ2AK9W3GNHJ2Q
  • hookWorkflow is not resumable via public webhook endpoint | wrun_01KYNNDGGFHHA9DCQR1P8F2K0R
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01KYNNDR3DHGB7WRXM8WEEWK1S
  • sleepingWorkflow | wrun_01KYNNES0GR0GT5VDDQA4ZF7SN
  • outputStreamWorkflow negative startIndex (reads from end)
  • outputStreamWorkflow - getTailIndex and getStreamChunks getTailIndex returns correct index after stream completes
  • outputStreamWorkflow - getTailIndex and getStreamChunks getTailIndex returns -1 before any chunks are written
  • outputStreamWorkflow - getTailIndex and getStreamChunks getStreamChunks returns same content as reading the stream
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01KYNNP9SFY6KA4RRVX81XGZET
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01KYNNPN5H04VCF0SZ5Q4N0QFT
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01KYNNPVZ64MD5M4XK43NVWAT4
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01KYNNQ9HCN0VQCDBAB80WQG4Q
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01KYNNR2YEWSAEHZ2BQF4093MJ
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01KYNNR60K3Q079217JBGWBSBZ
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01KYNNRBGDH5KHB7QXVC71Y3EA
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01KYNNRF5XVFJDRJGMN6WD7WSV
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01KYNNRQGFGRZPYBRGQZ80HXE5
  • pages router sleepingWorkflow via pages router
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01KYNNXZRTGAJE930FE77SKC24

turso (83 failed):

  • addTenWorkflow | wrun_01KYNNCARPW64TCNG8X443VG6W
  • addTenWorkflow | wrun_01KYNNCARPW64TCNG8X443VG6W
  • deploymentId: 'latest' is a no-op in non-Vercel worlds
  • wellKnownAgentWorkflow (.well-known/agent) | wrun_01KYNNDHSEFFKY5ZKY79Q1DDBA
  • should work with react rendering in step
  • promiseAllWorkflow | wrun_01KYNNCJ1Z5BD58GD27SR62S4T
  • promiseRaceWorkflow | wrun_01KYNNCQHVA1M9YQEQKN9M6G75
  • promiseAnyWorkflow | wrun_01KYNNCVPVDK1E5XNE8TM7R1JH
  • importedStepOnlyWorkflow | wrun_01KYNNDXNN097Y6ZVCQ255AGJ0
  • readableStreamWorkflow | wrun_01KYNNCXPVAWCY6DHC178J5PZK
  • hookWorkflow | wrun_01KYNND9ZDV2SJ2AK9W3GNHJ2Q
  • hookWorkflow is not resumable via public webhook endpoint | wrun_01KYNNDGGFHHA9DCQR1P8F2K0R
  • webhookWorkflow | wrun_01KYNNDMBZ0Q3CB49QVYE71YP0
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01KYNNDR3DHGB7WRXM8WEEWK1S
  • sleepingWorkflow | wrun_01KYNNES0GR0GT5VDDQA4ZF7SN
  • parallelSleepWorkflow | wrun_01KYNNF8F8CWSY8CQXBG2A0246
  • sleepWinsRaceWorkflow | wrun_01KYNNFBM01PBRHERFEFHP0DN9
  • stepWinsRaceWorkflow | wrun_01KYNNFEPW5N1SDVY59RDN23T8
  • nullByteWorkflow | wrun_01KYNNFHZTZPBKA10QBNRF50Q1
  • workflowAndStepMetadataWorkflow | wrun_01KYNNFM2WP9DEQ6GJMKJAD09X
  • outputStreamWorkflow no startIndex (reads all chunks)
  • outputStreamWorkflow positive startIndex (skips first chunk)
  • outputStreamWorkflow negative startIndex (reads from end)
  • outputStreamWorkflow - getTailIndex and getStreamChunks getTailIndex returns correct index after stream completes
  • outputStreamWorkflow - getTailIndex and getStreamChunks getTailIndex returns -1 before any chunks are written
  • outputStreamWorkflow - getTailIndex and getStreamChunks getStreamChunks returns same content as reading the stream
  • outputStreamInsideStepWorkflow - getWritable() called inside step functions | wrun_01KYNNHZ4A21WWVZ7P54FJZFYG
  • writableForwardedFromWorkflowWorkflow | wrun_01KYNNJBP15YE2WX78MGV7XBAW
  • writableForwardedFromStepWorkflow | wrun_01KYNNJFP3WT9JGWN3PYRQHRKN
  • fetchWorkflow | wrun_01KYNNJJYWCG68H8AG2643AMHH
  • promiseRaceStressTestWorkflow | wrun_01KYNNJP3FJMM13Q119KYRBT30
  • error handling error propagation workflow errors nested function calls preserve message and stack trace
  • error handling error propagation workflow errors cross-file imports preserve message and stack trace
  • error handling error propagation step errors basic step error preserves message and stack trace
  • error handling error propagation step errors cross-file step error preserves message and function names in stack
  • error handling retry behavior regular Error retries until success
  • error handling retry behavior FatalError fails immediately without retries
  • error handling retry behavior RetryableError respects custom retryAfter delay
  • error handling retry behavior maxRetries=0 disables retries
  • error handling catchability FatalError can be caught and detected with FatalError.is()
  • error handling not registered WorkflowNotRegisteredError fails the run when workflow does not exist
  • error handling not registered StepNotRegisteredError fails the step but workflow can catch it
  • error handling not registered StepNotRegisteredError fails the run when not caught in workflow
  • hookCleanupTestWorkflow - hook token reuse after workflow completion | wrun_01KYNNNXB84V835E2T08R9S55M
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01KYNNP9SFY6KA4RRVX81XGZET
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01KYNNPN5H04VCF0SZ5Q4N0QFT
  • 'hookGetConflictWithPriorStepWorkflow' - hook.getConflict() does not block step execution | wrun_01KYNNPQDK3YT9337QV7PV27YD
  • 'hookGetConflictWithParallelStepWorkfl…' - hook.getConflict() does not block step execution | wrun_01KYNNPSRC90GDH8E4QQ9SP1SP
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01KYNNPVZ64MD5M4XK43NVWAT4
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01KYNNQ9HCN0VQCDBAB80WQG4Q
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01KYNNR2YEWSAEHZ2BQF4093MJ
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01KYNNR60K3Q079217JBGWBSBZ
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01KYNNRBGDH5KHB7QXVC71Y3EA
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01KYNNRF5XVFJDRJGMN6WD7WSV
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01KYNNRQGFGRZPYBRGQZ80HXE5
  • hookDisposeTestWorkflow - hook token reuse after explicit disposal while workflow still running | wrun_01KYNNRY2N5GB2DXCEN3XM4D19
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars) | wrun_01KYNNSC507XKPZJSYD5QY79SP
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument | wrun_01KYNNSMPJ2ZRWKAJ5GJ1RQ6NG
  • closureVariableWorkflow - nested step functions with closure variables | wrun_01KYNNSSTC2DAJGE8Q5SSC86NV
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step | wrun_01KYNNSW1JMKBYB4NJ5ZAVE3D7
  • health check (queue-based) - workflow and step endpoints respond to health check messages
  • health check (CLI) - workflow health command reports healthy endpoints
  • pathsAliasWorkflow - TypeScript path aliases resolve correctly | wrun_01KYNNTAYBG8PEFZZK7A7SB5BY
  • Calculator.calculate - static workflow method using static step methods from another class | wrun_01KYNNTGA948JWT1TZWRAN2Z94
  • AllInOneService.processNumber - static workflow method using sibling static step methods | wrun_01KYNNTPSZRQVXDT4R3B68VXT4
  • ChainableService.processWithThis - static step methods using this to reference the class | wrun_01KYNNTX1BGSJR8HWCYEZCX2TW
  • thisSerializationWorkflow - step function invoked with .call() and .apply() | wrun_01KYNNV3E1S7AK66GMFDGKPMKE
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE | wrun_01KYNNVA5W38T7YJ9BRSAR6VHN
  • instanceMethodStepWorkflow - instance methods with "use step" directive | wrun_01KYNNVGTFNZJ3PEPY4883H8PZ
  • crossContextSerdeWorkflow - classes defined in step code are deserializable in workflow context | wrun_01KYNNVWMC66KKHQWSPPRH07YW
  • stepFunctionAsStartArgWorkflow - step function reference passed as start() argument | wrun_01KYNNW43JBB3GXX4EMV48Q4H7
  • cancelRun - cancelling a running workflow | wrun_01KYNNWACCSQGTP706G8FW48MJ
  • cancelRun via CLI - cancelling a running workflow | wrun_01KYNNWF7ET4PXWKKGKSTMW0ZZ
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router
  • hookWithSleepWorkflow - hook payloads delivered correctly with concurrent sleep | wrun_01KYNNWPFA9VZHASGM61YZ8TM9
  • hookWithSleepFinalStepWorkflow - step only on final payload | wrun_01KYNNX256S6WM92JEWESYW39M
  • sleepInLoopWorkflow - sleep inside loop with steps actually delays each iteration | wrun_01KYNNXA0KV0V0JATHMYFJXBFD
  • sleepWithSequentialStepsWorkflow - sequential steps work with concurrent sleep (control) | wrun_01KYNNXN8B15BC58VVBMHW8WSX
  • importMetaUrlWorkflow - import.meta.url is available in step bundles | wrun_01KYNNXVJAVG892TVF1ZH5V9JX
  • metadataFromHelperWorkflow - getWorkflowMetadata/getStepMetadata work from module-level helper (#1577) | wrun_01KYNNXXKX8NAN6MEPPPHGM8RH
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01KYNNXZRTGAJE930FE77SKC24

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 97 0 8
✅ example 97 0 8
✅ express 97 0 8
✅ fastify 97 0 8
✅ hono 97 0 8
✅ nextjs-turbopack 102 0 3
✅ nextjs-webpack 102 0 3
✅ nitro 97 0 8
✅ nuxt 97 0 8
✅ sveltekit 97 0 8
✅ vite 97 0 8
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 99 0 6
✅ express-stable 99 0 6
✅ fastify-stable 99 0 6
✅ hono-stable 99 0 6
✅ nextjs-turbopack-canary 86 0 19
✅ nextjs-turbopack-stable 105 0 0
✅ nextjs-webpack-canary 86 0 19
✅ nextjs-webpack-stable 105 0 0
✅ nitro-stable 99 0 6
✅ nuxt-stable 99 0 6
✅ sveltekit-stable 99 0 6
✅ vite-stable 99 0 6
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 99 0 6
✅ express-stable 99 0 6
✅ fastify-stable 99 0 6
✅ hono-stable 99 0 6
✅ nextjs-turbopack-canary 86 0 19
✅ nextjs-turbopack-stable 105 0 0
✅ nextjs-webpack-canary 86 0 19
✅ nextjs-webpack-stable 105 0 0
✅ nitro-stable 99 0 6
✅ nuxt-stable 99 0 6
✅ sveltekit-stable 99 0 6
✅ vite-stable 99 0 6
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 99 0 6
✅ express-stable 99 0 6
✅ fastify-stable 99 0 6
✅ hono-stable 99 0 6
✅ nextjs-turbopack-canary 86 0 19
✅ nextjs-turbopack-stable 105 0 0
✅ nextjs-webpack-canary 86 0 19
✅ nextjs-webpack-stable 105 0 0
✅ nitro-stable 99 0 6
✅ nuxt-stable 99 0 6
✅ sveltekit-stable 99 0 6
✅ vite-stable 99 0 6
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 105 0 0
❌ 🌍 Community Worlds
App Passed Failed Skipped
✅ mongodb-dev 4 0 3
✅ redis-dev 4 0 3
❌ redis 67 19 0
✅ turso-dev 4 0 3
❌ turso 3 83 0
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 99 0 6
✅ e2e-local-dev-tanstack-start-stable 99 0 6
✅ e2e-local-postgres-nest-stable 99 0 6
✅ e2e-local-postgres-tanstack-start-stable 99 0 6
✅ e2e-local-prod-nest-stable 99 0 6
✅ e2e-local-prod-tanstack-start-stable 99 0 6

📋 View full workflow run

@TooTallNate TooTallNate left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Faithful backport. I verified it mechanically rather than by reading, and pushed no fixes — nothing needed changing.

Method

For each file I compared the change #3139 made on main against the change this PR makes on stable, hunk by hunk (diff of the +/- lines of git diff 0d6ec4387 2941b1c36 -- <file> vs git diff stable backport -- <file>), so pre-existing mainstable divergence cancels out and only genuine backport deltas remain.

file result
workflow/hook.ts byte-identical change
workflow/sleep.ts byte-identical change
private.ts identical but for 3 doc lines
step.ts 4 deltas, all necessary — below
step-delivery-ordering.test.ts API renames only, no logic changed
step-delivery-hop-count.test.ts API renames + error-shape adaptation
delivery-barrier-coverage.test.ts abort case removed + API renames, nothing else
.changeset drops "aborts"

Every deviation, and why each is right

Abort dropped. packages/core/src/workflow/abort-controller.ts doesn't exist on stable, so the abort hunk, the abort describe, the changeset mention, and the "three cases" docblock (now "two", with an explicit note that the case isn't portable) are all correctly removed. I checked this is a complete omission rather than a partial one: stable has no abort/signal source files at all, and the only AbortController string in packages/core/src is an unrelated doc mention in step-hydration-cache.ts. pendingDeliveries++ appears only in hook.ts and step.ts on stable, so there's no third delivery participant that should have been wired in.

ReplayPayloadCachestepHydrationCache. stable has no replay-payload-cache.ts; step_completed correctly uses getOrHydrateStepReturnValue(ctx.stepHydrationCache, …) in place of ctx.replayPayloadCache.getStepResult(…). Renames are applied consistently through comments and test harnesses. Zero dangling references — I grepped the changed files for ReplayPayloadCache, replayPayloadCache, prepareEventPayload, primitiveStepResults, getStepResult, hydrateStepError, dehydrateStepError, abort-controller, _setAborted: all absent.

step_failed restructured, not weakened. This is the delta worth the most scrutiny, because stable's handler is a different shape: it builds a FatalError synchronously from eventData.error.message/stack, where main awaits hydrateStepError. The backport keeps the semantics that matter — barrier registered as 'step', deferral captured at event-consumption time, reject moved into the detached earlierDelivered.then(…) — and correctly omits pendingDeliveries++/--, since there's no async hydration window to hold the counter across. That matches main's effective behaviour anyway: there the counter is released in the slot's finally, before the detached defer, so both branches sit at 0 during the defer window.

One comment rewritten. stable has a stepHydrationCache comment claiming the cache lookup happens in the queue slot "(and still resolves via resolve)". The backport drops that parenthetical, which the fix makes false. main never had it. Good catch by whoever resolved this — easy thing to leave stale.

dehydrateStepError → plain { message, stack } in the hop-count fixture, matching what stable's handler actually reads.

CorruptedEventLogErrorReplayDivergenceError in one docblock line. Both types exist on stable; this preserves the wording already there rather than importing main's. Fine either way, and it's a comment.

The tests are still real guards

The failure mode I was most worried about in an AI-resolved backport is a test adapted into something that passes trivially. So I reverted each fix individually on this branch and confirmed the corresponding guard fires:

revert result
DEFER_BEHIND.step drops 'step' step-vs-step test fails
sleep.ts deferral read late again wait hop tests fail at 8/20/50
hook.ts deferral read late again hook hop tests fail at 8/20/50
resolvesOnItsOwn memo removed scan guard takes 90.6 s (vs instant)
step_failed detached reject removed all 6 step-failure hop cases fail
step_completed detached resolve removed 15 failures across all three files

Also: no it.fails / it.skip / .only anywhere in the three new test files, and the suite's 3 expected-fails are pre-existing on stable (workflow.test.ts, hook-sleep-interaction.test.ts) — same two files as before the backport.

Local verification

Build and typecheck clean. packages/core unit suite 43 files, 824 passed | 3 expected fail. The 12 ordering-sensitive files run 8× consecutively, 209 passed | 3 expected fail every time. Biome reports the same 5 pre-existing complexity warnings as the unmodified stable, none new.

Note on CI — it had not run

Worth flagging beyond this PR: every workflow here was sitting in action_required because the PR was opened by github-actions[bot], so Tests, Lint, Docs Checks and Event Log Race Repro had never executed. The only green checks were Socket, DCO and the Vercel deploys, which is easy to misread as "CI passing". I approved the runs.

Post-approval, everything relevant is green: Unit Tests on both ubuntu and windows, Vitest Plugin Tests, Node.js Module Build Errors, all E2E Local Dev / Local Prod / Local Postgres apps, all 11 E2E Vercel Prod apps, E2E Windows, E2E Required Check, and Lint.

The only failures are E2E Community World (Turso), (Redis) and (MongoDB) — which fail and cancel identically on each of the last four stable pushes, including at this PR's merge base 99d1a0ce1. Pre-existing and unrelated.

The later Merge branch 'stable' commit only pulled in unrelated stable work (version packages, world-vercel timeouts); all 8 backported files are byte-identical to what I reviewed at 61d0fbcc1.

Approving.

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