Skip to content

Backport #3439: [core] Gate the unconsumed-event check on delivery idleness - #3442

Merged
VaguelySerious merged 1 commit into
stablefrom
backport/pr-3439-to-stable
Aug 11, 2026
Merged

Backport #3439: [core] Gate the unconsumed-event check on delivery idleness#3442
VaguelySerious merged 1 commit into
stablefrom
backport/pr-3439-to-stable

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

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

AI recommendation: This is a pure correctness fix (patch changeset) for a real defect that exists on stable: the unconsumed-event check's fixed DEFERRED_CHECK_DELAY_MS window races in-flight deliveries and raises a spurious ReplayDivergenceError, which escalates to CorruptedEventLogError and kills otherwise healthy runs. The touched files (packages/core/src/events-consumer.ts, private.ts, workflow.ts) all exist on stable with the same timing-bet logic, and the change adds only an internal predicate plus tests, no user-facing API or feature. Note that stable lacks the hasParkedCommittedDelivery/delivery-barrier machinery from #3183, so the cherry-pick will need adaptation and careful review.

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

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6233a82

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 Aug 11, 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 Aug 11, 2026 2:05am
example-nextjs-workflow-webpack Ready Ready Preview Aug 11, 2026 2:05am
example-workflow Ready Ready Preview Aug 11, 2026 2:05am
workbench-astro-workflow Ready Ready Preview Aug 11, 2026 2:05am
workbench-express-workflow Ready Ready Preview Aug 11, 2026 2:05am
workbench-fastify-workflow Ready Ready Preview Aug 11, 2026 2:05am
workbench-hono-workflow Ready Ready Preview Aug 11, 2026 2:05am
workbench-nestjs-workflow Ready Ready Preview Aug 11, 2026 2:05am
workbench-nitro-workflow Ready Ready Preview Aug 11, 2026 2:05am
workbench-nuxt-workflow Ready Ready Preview Aug 11, 2026 2:05am
workbench-python-workflow Error Error Aug 11, 2026 2:05am
workbench-sveltekit-workflow Ready Ready Preview Aug 11, 2026 2:05am
workbench-tanstack-start-workflow Ready Ready Preview Aug 11, 2026 2:05am
workbench-vite-workflow Ready Ready Preview Aug 11, 2026 2:05am
workflow-docs Ready Ready Preview, v0 Aug 11, 2026 2:05am
workflow-swc-playground Ready Ready Preview Aug 11, 2026 2:05am
workflow-tarballs Ready Ready Preview Aug 11, 2026 2:05am
workflow-web Ready Ready Preview Aug 11, 2026 2:05am

Signed-off-by: Peter Wielander <mittgfu@gmail.com>
@VaguelySerious
VaguelySerious force-pushed the backport/pr-3439-to-stable branch from feb1545 to 6233a82 Compare August 11, 2026 02:02
@github-actions

github-actions Bot commented Aug 11, 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 83 101 9 193
✅ 📋 Other 594 0 36 630
Total 5381 101 381 5863

❌ Failed Tests

🌍 Community Worlds (101 failed)

redis (18 failed):

  • hookWorkflow is not resumable via public webhook endpoint | wrun_01KZQ91099BNMFAV93QM7R9JE3
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01KZQ91AX9BNX430NDCJN3HFCR
  • sleepingWorkflow | wrun_01KZQ928Z7PE25C6YGFSHFSPCV
  • 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_01KZQ99XW60JKF5HQR6B21RR0P
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01KZQ9A9SDH5F834AT3FYZ055Z
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01KZQ9AHM9FENG810P7BHGD4KX
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01KZQ9AZ1W52AQNA0NY5SQ14J4
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01KZQ9BSAEN47TCBEXX0G9D46G
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01KZQ9BXRK5Z0Z1H68HTMYHQ7E
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01KZQ9C4045VG13BDRNM6ZW7M0
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01KZQ9C95JGT7MDH87ZFTCCFJ4
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01KZQ9CJ3D597EV6XYHZ8WC6Y7
  • pages router sleepingWorkflow via pages router
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01KZQ9HW5ME6E6J64JJG61FYG1

turso (83 failed):

  • addTenWorkflow | wrun_01KZQ8ZVK0YF5SK4QG58P4VA47
  • addTenWorkflow | wrun_01KZQ8ZVK0YF5SK4QG58P4VA47
  • deploymentId: 'latest' is a no-op in non-Vercel worlds
  • wellKnownAgentWorkflow (.well-known/agent) | wrun_01KZQ90BAKJMCHC42B4ZMHX8JH
  • should work with react rendering in step
  • promiseAllWorkflow | wrun_01KZQ9027VG9NKQAMBQ9HGPK2Z
  • promiseRaceWorkflow | wrun_01KZQ906XDPXNCDYSWVY13YCBD
  • promiseAnyWorkflow | wrun_01KZQ9099SEP0BKRKRTBRVEY67
  • importedStepOnlyWorkflow | wrun_01KZQ90N6J21830V15CCSNJ0MK
  • readableStreamWorkflow | wrun_01KZQ90BRWREBGXQVHS0W4VCCA
  • hookWorkflow | wrun_01KZQ90R5BW5AWQYCAF1EFT9RW
  • hookWorkflow is not resumable via public webhook endpoint | wrun_01KZQ91099BNMFAV93QM7R9JE3
  • webhookWorkflow | wrun_01KZQ914NW9G09R0J9PS4Y8N97
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01KZQ91AX9BNX430NDCJN3HFCR
  • sleepingWorkflow | wrun_01KZQ928Z7PE25C6YGFSHFSPCV
  • parallelSleepWorkflow | wrun_01KZQ92RHNXZY1AB8RHF2KCWGB
  • sleepWinsRaceWorkflow | wrun_01KZQ92W1TN7S79RYBS3YP53T9
  • stepWinsRaceWorkflow | wrun_01KZQ92ZQ607662NR91285KHT0
  • nullByteWorkflow | wrun_01KZQ9338X51SP18MDP3SR0RK6
  • workflowAndStepMetadataWorkflow | wrun_01KZQ935KWR758HWGHTD476W9T
  • 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_01KZQ95DZ4Y1A78TE27DHPGMF7
  • writableForwardedFromWorkflowWorkflow | wrun_01KZQ95VTVA0TD163QE9K3DQB2
  • writableForwardedFromStepWorkflow | wrun_01KZQ9609ARY2XY1WTMS7V6X1H
  • fetchWorkflow | wrun_01KZQ963YC88701QHHVF5HG1PC
  • promiseRaceStressTestWorkflow | wrun_01KZQ967DJBXSEKZ2FNGH1PH7Z
  • 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_01KZQ99GQDTQ80FC487ZZ76S45
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01KZQ99XW60JKF5HQR6B21RR0P
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01KZQ9A9SDH5F834AT3FYZ055Z
  • 'hookGetConflictWithPriorStepWorkflow' - hook.getConflict() does not block step execution | wrun_01KZQ9ACCS140ZWGERK1J9GJ84
  • 'hookGetConflictWithParallelStepWorkfl…' - hook.getConflict() does not block step execution | wrun_01KZQ9AEVTFJ4KFY92PT798EY3
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01KZQ9AHM9FENG810P7BHGD4KX
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01KZQ9AZ1W52AQNA0NY5SQ14J4
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01KZQ9BSAEN47TCBEXX0G9D46G
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01KZQ9BXRK5Z0Z1H68HTMYHQ7E
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01KZQ9C4045VG13BDRNM6ZW7M0
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01KZQ9C95JGT7MDH87ZFTCCFJ4
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01KZQ9CJ3D597EV6XYHZ8WC6Y7
  • hookDisposeTestWorkflow - hook token reuse after explicit disposal while workflow still running | wrun_01KZQ9CS9HN2CY2NABW7NF94K6
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars) | wrun_01KZQ9D8G3P1ZA7J0QB873G1XD
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument | wrun_01KZQ9DGXMASBNM8HFPB8KBF64
  • closureVariableWorkflow - nested step functions with closure variables | wrun_01KZQ9DPB9HVMVFBAK37B7RY9F
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step | wrun_01KZQ9DRXWSCREPX17MPTQVJFJ
  • 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_01KZQ9E7000PTYJ5D2KQHHBN9V
  • Calculator.calculate - static workflow method using static step methods from another class | wrun_01KZQ9ECC3PQ9Z1XEWJ33H3JR8
  • AllInOneService.processNumber - static workflow method using sibling static step methods | wrun_01KZQ9EHMSYP7RTFVPHK97150B
  • ChainableService.processWithThis - static step methods using this to reference the class | wrun_01KZQ9EQ5R4F91VKX6P08785AJ
  • thisSerializationWorkflow - step function invoked with .call() and .apply() | wrun_01KZQ9EXQ6J9PXMN0E31RG96AN
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE | wrun_01KZQ9F4HVA67H3FD6HWY6FR05
  • instanceMethodStepWorkflow - instance methods with "use step" directive | wrun_01KZQ9FB0S8YTQ8GG9C9A2MSDH
  • crossContextSerdeWorkflow - classes defined in step code are deserializable in workflow context | wrun_01KZQ9FNZ2H0M3B1ZRQAYJCVZR
  • stepFunctionAsStartArgWorkflow - step function reference passed as start() argument | wrun_01KZQ9FXY8TH8S58CX099PYQ9P
  • cancelRun - cancelling a running workflow | wrun_01KZQ9G4F6PB565CK5A7DNBVGP
  • cancelRun via CLI - cancelling a running workflow | wrun_01KZQ9G929255HPSH785M6RAVK
  • 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_01KZQ9GFZ2YRBMQEZGFFDBBW68
  • hookWithSleepFinalStepWorkflow - step only on final payload | wrun_01KZQ9GVZD93VACY6V5WZC8DZY
  • sleepInLoopWorkflow - sleep inside loop with steps actually delays each iteration | wrun_01KZQ9H4G7KRCSG70ZER6EB1EP
  • sleepWithSequentialStepsWorkflow - sequential steps work with concurrent sleep (control) | wrun_01KZQ9HFH6FZEW7T1MW55PAJGE
  • importMetaUrlWorkflow - import.meta.url is available in step bundles | wrun_01KZQ9HQ8P79N7S04R6WJS4E8M
  • metadataFromHelperWorkflow - getWorkflowMetadata/getStepMetadata work from module-level helper (#1577) | wrun_01KZQ9HSNPVN9VX2PSD8PB5084
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01KZQ9HW5ME6E6J64JJG61FYG1

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 68 18 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

@VaguelySerious

Copy link
Copy Markdown
Member

(AI) Rebased onto current stable and resolved the conflict.

What caused it: the branch was cut when stable was at e822a6a173. Since then #3173 (backport of #3139) landed, which adds the delivery-barrier machinery to private.ts. The PR description's note that "stable lacks the hasParkedCommittedDelivery/delivery-barrier machinery" is now stale.

Resolution: because stable now has hasParkedCommittedDelivery and awaitEarlierDeliveries, the adaptation is no longer needed and the change converges on upstream. isDeliveryIdle / scheduleWhenIdle are now byte-identical to main:

export function isDeliveryIdle(ctx: WorkflowOrchestratorContext): boolean {
  return ctx.pendingDeliveries === 0 && !hasParkedCommittedDelivery(ctx);
}

The previous resolution had adapted this to pendingDeliveries === 0 alone. Keeping that would have been a regression: scheduleWhenIdle on stable checks pendingDeliveries > 0 || hasParkedCommittedDelivery(ctx), so routing it through a predicate that drops the second half would have silently reverted part of #3173. hasParkedCommittedDelivery stays unexported (nothing on stable imports it); the only other deviation from main is the two pre-existing stable gaps, no retained-session append() and no WORKFLOW_DEFERRED_CHECK_DELAY_MS override knob (envNumber does not exist in stable's world package), so the delay stays the DEFERRED_CHECK_DELAY_MS constant.

Validation: @workflow/core builds, typechecks, and all 836 src/ unit tests pass (the 6 e2e/ failures locally are the usual unbuilt-workbench/env-dependent ones).

Worth flagging for review: the shipped unconsumed-check-delivery-idle.test.ts only ever drives pendingDeliveries and leaves pendingDeliveryBarriers empty, so it passes under either version of the predicate. I wrote a throwaway test (not committed) that registers an armed step barrier with pendingDeliveries === 0, the parked-committed window from #3183. It fails 2/2 under the dropped-guard version and passes here. delivery-barrier-coverage.test.ts:536 also catches it, so CI would have gone red rather than merging the regression silently.

The workbench-python-workflow deployment failure is pre-existing: it fails on stable (6f301ba396) and on the previous PR head too.

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