Skip to content

Backport #3882: fix(core): stop reconnecting cancelled streams - #3920

Merged
VaguelySerious merged 2 commits into
stablefrom
backport/pr-3882-to-stable
Sep 11, 2026
Merged

VaguelySerious merged 2 commits into
stablefrom
backport/pr-3882-to-stable

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

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

AI recommendation: This is a pure bug fix (resource leak / incorrect reconnect after cancellation) in createReconnectingFramedStream, plus regression tests and a patch changeset — no new API surface or behavior additions. I verified the affected code exists on stable (packages/core/src/serialization.ts line 702 onward) with the same unlatched cancel and unconditional reconnect()/connect() paths, so stable carries the same defect (reopened, unowned World readers leading to retained listeners/intervals and MaxListenersExceededWarning).

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

Cancelling a reconnecting framed stream could be mistaken for a clean, incomplete EOF. The pending pull then reopened the World stream after cancellation, leaving the new reader unowned; local World consumers retained emitter listeners and polling intervals, eventually producing `MaxListenersExceededWarning` after repeated reads of the same durable stream.

The reader now latches cancellation across pending reads, completion checks, and reconnect acquisition. Reconnect work stops after cancellation, and a World stream that finishes opening after cancellation is immediately cancelled instead of being installed as the active reader.

Added focused regressions for cancellation while completion metadata is pending and while a reconnect acquisition is pending. The complete `@workflow/core` suite passes: 107 test files passed, 1 skipped; 2,285 tests passed, 3 expected failures, and 1 skipped. `@workflow/core` also typechecks. Before applying the fix, a 20-turn local eve session deterministically retained one World reader per turn and warned on listener 11; with this change, the same run peaked at one reader and ended with zero.

Signed-off-by: Casey Gowrie <casey.gowrie@vercel.com>
@github-actions
github-actions Bot requested review from a team and ijjk as code owners September 1, 2026 15:49
@changeset-bot

changeset-bot Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 174f8c3

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 Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
example-nextjs-workflow-turbopack Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
example-nextjs-workflow-webpack Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
example-workflow Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workbench-astro-workflow Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workbench-express-workflow Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workbench-fastify-workflow Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workbench-hono-workflow Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workbench-nestjs-workflow Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workbench-nitro-workflow Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workbench-nuxt-workflow Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workbench-python-workflow Error Error v0 Sep 10, 2026 9:59pm UTC
workbench-sveltekit-workflow Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workbench-tanstack-start-workflow Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workbench-vite-workflow Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workflow-docs Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workflow-swc-playground Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workflow-tarballs Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC
workflow-web Ready Ready Preview, v0 Sep 10, 2026 9:59pm UTC

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor Author

🧪 E2E Test Results

❌ Some tests failed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 1099 0 78 1177
✅ 💻 Local Development 1198 0 86 1284
✅ 📦 Local Production 1198 0 86 1284
✅ 🐘 Local Postgres 1198 0 86 1284
✅ 🪟 Windows 107 0 0 107
❌ 🌍 Community Worlds 82 106 9 197
✅ 📋 Other 606 0 36 642
Total 5488 106 381 5975

❌ Failed Tests

🌍 Community Worlds (106 failed)

redis (21 failed):

  • hookWorkflow | wrun_01M26N9SRCWZ9AW55J4XV7JWY4
  • hookWorkflow is not resumable via public webhook endpoint | wrun_01M26NA0QYDAK9M3J394VN4ACP
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01M26NAB4Y075HVDQKH4CH15NZ
  • sleepingWorkflow | wrun_01M26NBA0GV8SS7S3YG8K005X7
  • 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
  • error handling serialization failures step-argument serialization failure is catchable in workflow code
  • error handling serialization failures uncaught step-argument serialization failure fails the run as USER_ERROR without redelivery retries
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01M26NK40C2E6P4GCCBTFTTJ9Q
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01M26NKDNC50BENKQJZ7Z1NZGN
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01M26NKMCAPF6N2NEN4Z6SX13X
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01M26NM2GVEH1F5FEKB6R9P538
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01M26NMVDH70Y9QZREFVP2B903
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01M26NMZJFWSXQKP14BJXM2MRP
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01M26NN4PTPY6QEK2QGMSBGKXT
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01M26NN90N896KKXBK5FYQ25CE
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01M26NNH1YD5VFN74RBDKQRAAB
  • pages router sleepingWorkflow via pages router
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01M26NT8C7X0X2EGTEWABT9SVX

turso (85 failed):

  • addTenWorkflow | wrun_01M26N8X00GZPF1NDEX04J8HYN
  • addTenWorkflow | wrun_01M26N8X00GZPF1NDEX04J8HYN
  • deploymentId: 'latest' is a no-op in non-Vercel worlds
  • wellKnownAgentWorkflow (.well-known/agent) | wrun_01M26N9G1TDBER96G9Q4XN37FP
  • should work with react rendering in step
  • promiseAllWorkflow | wrun_01M26N92Z3C1SHPBGFS845JD5P
  • promiseRaceWorkflow | wrun_01M26N98H8G3M8J76B6MED3RGR
  • promiseAnyWorkflow | wrun_01M26N9ANZ6MFBMFDM7JTD6V6H
  • importedStepOnlyWorkflow | wrun_01M26N9V88PRXYBR1V0517KEBA
  • readableStreamWorkflow | wrun_01M26N9CVHTM15P0XBK5WG5Y6W
  • hookWorkflow | wrun_01M26N9SRCWZ9AW55J4XV7JWY4
  • hookWorkflow is not resumable via public webhook endpoint | wrun_01M26NA0QYDAK9M3J394VN4ACP
  • webhookWorkflow | wrun_01M26NA516P14GXAN6Y26HWV90
  • parallelStepsThenWebhookWorkflow - no hook_conflict from same-tick replay race | wrun_01M26NAB4Y075HVDQKH4CH15NZ
  • sleepingWorkflow | wrun_01M26NBA0GV8SS7S3YG8K005X7
  • parallelSleepWorkflow | wrun_01M26NBR75XPNDH9Z2W4BRHD82
  • sleepWinsRaceWorkflow | wrun_01M26NBVH9K53B2G4E4DXDJG6F
  • stepWinsRaceWorkflow | wrun_01M26NBYY9CWH00VPWCXWNDKMA
  • nullByteWorkflow | wrun_01M26NC26TZZA310XMZJFBWV7P
  • workflowAndStepMetadataWorkflow | wrun_01M26NC4KNJXXXJBBKDEMC07RH
  • 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_01M26NEKG29P3B0HJ7E92VDPPQ
  • writableForwardedFromWorkflowWorkflow | wrun_01M26NF01T07A6K2B26AGH059E
  • writableForwardedFromStepWorkflow | wrun_01M26NF47G28PK759RK08581DS
  • fetchWorkflow | wrun_01M26NF7V4V2F7R25N54T85YM2
  • promiseRaceStressTestWorkflow | wrun_01M26NFB5GFTPB7E6DGAZK3VFE
  • 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 serialization failures step-argument serialization failure is catchable in workflow code
  • error handling serialization failures uncaught step-argument serialization failure fails the run as USER_ERROR without redelivery retries
  • 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_01M26NJSWG2SY5QX5YF5TSSCWE
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously | wrun_01M26NK40C2E6P4GCCBTFTTJ9Q
  • hookGetConflictWorkflow - awaiting hook.getConflict() registers hook without payload | wrun_01M26NKDNC50BENKQJZ7Z1NZGN
  • 'hookGetConflictWithPriorStepWorkflow' - hook.getConflict() does not block step execution | wrun_01M26NKG0GFSPN58SC2K7ZX3RB
  • 'hookGetConflictWithParallelStepWorkfl…' - hook.getConflict() does not block step execution | wrun_01M26NKJ5EXC0P4DP6WWDV7219
  • hookGetConflictThenStepParallelWorkflow - hook.getConflict() continuation step runs alongside other steps | wrun_01M26NKMCAPF6N2NEN4Z6SX13X
  • hookGetConflictWorkflow - hook.getConflict() resolves with the conflicting run when token is already registered | wrun_01M26NM2GVEH1F5FEKB6R9P538
  • hookClaimOnlyMutexWorkflow - hook works as a pure run mutex without payload data | wrun_01M26NMVDH70Y9QZREFVP2B903
  • hookAdoptOwnerResultWorkflow - duplicate adopts the owner result via conflict.returnValue | wrun_01M26NMZJFWSXQKP14BJXM2MRP
  • hookSignalOwnerWorkflow - duplicate forwards its payload to the owner via resumeHook | wrun_01M26NN4PTPY6QEK2QGMSBGKXT
  • hookSupersedeOwnerWorkflow - duplicate cancels the owner and claims the released token | wrun_01M26NN90N896KKXBK5FYQ25CE
  • resume-or-start route pattern - resumeHook retried after start() reaches the new run | wrun_01M26NNH1YD5VFN74RBDKQRAAB
  • hookDisposeTestWorkflow - hook token reuse after explicit disposal while workflow still running | wrun_01M26NNR1W4VK91AGF8GY3469B
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars) | wrun_01M26NP5FRBVHYNBBDEG46HSV6
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument | wrun_01M26NPCT5HV29BGKQG2KNGPVX
  • closureVariableWorkflow - nested step functions with closure variables | wrun_01M26NPHM15DMRM8K1X40HZD0A
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step | wrun_01M26NPKNK7CMT3H022BHPGTZD
  • 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_01M26NQ13FMCRX896KS7TZMZ26
  • Calculator.calculate - static workflow method using static step methods from another class | wrun_01M26NQ5WRYTEWNB2ZVFPA0G3X
  • AllInOneService.processNumber - static workflow method using sibling static step methods | wrun_01M26NQAKPEKVKMK7AGNRXZFKA
  • ChainableService.processWithThis - static step methods using this to reference the class | wrun_01M26NQFB95HGFFNFJJZ2G876F
  • thisSerializationWorkflow - step function invoked with .call() and .apply() | wrun_01M26NQNE017QQWVBFB721J8EP
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE | wrun_01M26NQVAFJYSHYN5JEDQWHRWY
  • instanceMethodStepWorkflow - instance methods with "use step" directive | wrun_01M26NR17KQ7MTR5WDS047JXB4
  • crossContextSerdeWorkflow - classes defined in step code are deserializable in workflow context | wrun_01M26NRAPEB86K91Q58NNAZS0P
  • stepFunctionAsStartArgWorkflow - step function reference passed as start() argument | wrun_01M26NRHTRGEHJCWJTFQ7ES4WX
  • cancelRun - cancelling a running workflow | wrun_01M26NRQWD28FGPRH6TW5PA4TY
  • cancelRun via CLI - cancelling a running workflow | wrun_01M26NRW3WJ53CTDJ1327XJ30Y
  • 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_01M26NS27T7VB2GDKQFYA5FSM3
  • hookWithSleepFinalStepWorkflow - step only on final payload | wrun_01M26NSC9SA8WHD91BAYV7DR9H
  • sleepInLoopWorkflow - sleep inside loop with steps actually delays each iteration | wrun_01M26NSKPVETFZ4EV3QQRKX7B0
  • sleepWithSequentialStepsWorkflow - sequential steps work with concurrent sleep (control) | wrun_01M26NSY4A1DRF1A0E6FDGJZKK
  • importMetaUrlWorkflow - import.meta.url is available in step bundles | wrun_01M26NT3X0T1RFSV7AEAEYFXGQ
  • metadataFromHelperWorkflow - getWorkflowMetadata/getStepMetadata work from module-level helper (#1577) | wrun_01M26NT68KWK0TWKVF75SW98ER
  • resilient start: addTenWorkflow completes when run_created returns 500 | wrun_01M26NT8C7X0X2EGTEWABT9SVX

Details by Category

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

📋 View full workflow run

@VaguelySerious
VaguelySerious merged commit b7385f0 into stable Sep 11, 2026
155 of 168 checks passed
@VaguelySerious
VaguelySerious deleted the backport/pr-3882-to-stable branch September 11, 2026 15:59

This branch had an error being deployed

1 failed and 17 active deployments
Preview – workflow-swc-playground — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – example-nextjs-workflow-turbopack — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – example-nextjs-workflow-webpack — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workbench-hono-workflow — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workbench-nuxt-workflow — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workbench-tanstack-start-workflow — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – example-workflow — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workflow-tarballs — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workbench-vite-workflow — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workbench-nitro-workflow — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workbench-express-workflow — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workbench-sveltekit-workflow — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workbench-nestjs-workflow — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workbench-astro-workflow — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workbench-fastify-workflow — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workflow-web — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workflow-docs — 174f8c3b Deployed Sep 10, 2026 by vercel[bot]
Preview – workbench-python-workflow — 174f8c3b Deployed Sep 10, 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