Skip to content

Backport #5041: fix(core): close stream reads cancelled while connecting - #5084

Open
github-actions[bot] wants to merge 1 commit into
stablefrom
backport/pr-5041-to-stable
Open

github-actions[bot] wants to merge 1 commit into
stablefrom
backport/pr-5041-to-stable

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

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

AI recommendation: This is a pure resource-leak fix: cancelling a WorkflowServerReadableStream while its World stream is still connecting left the underlying read (a live GET on world-vercel, a tail poller on world-local) open until the server's max duration. The buggy code path exists verbatim on stable (WorkflowServerReadableStream in packages/core/src/serialization.ts, whose cancel likewise only tears down an already-assigned #reader), and the commit is a patch changeset plus tests with no new API surface. Note the cherry-pick needs light adaptation: stable uses a synchronous getWorld()/world.readFromStream(name, startIndex) instead of getWorldLazy()/world.streams.get(runId, name, startIndex), so the "cancelled while the World loads" case and its test do not apply there.

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

A signal-bearing step that returns before its `_system_abort` read
connects cancels a stream that has no reader yet, so the World stream is
never closed. On world-vercel the GET stays open until the server's 120
s max duration, and on world-local the tail poller keeps running. On
iad1 today, about 8% of the abort-stream GETs that hit that cap came
from steps that finished before the server sent headers.

Added tests. The cases for cancelling while connecting and while the
World loads fail without the fix and pass with it. Checked locally that
cancelling an undici response body closes the connection, so a cancel
after the read connects already frees the socket.

---------

Signed-off-by: Alex Langenfeld <alex.langenfeld@vercel.com>
@changeset-bot

changeset-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f54f61d

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 Oct 26, 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 Oct 26, 2026 9:43pm UTC
example-nextjs-workflow-webpack Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
example-workflow Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workbench-astro-workflow Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workbench-express-workflow Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workbench-fastify-workflow Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workbench-hono-workflow Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workbench-nestjs-workflow Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workbench-nitro-workflow Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workbench-nuxt-workflow Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workbench-python-workflow Error Error v0 Oct 26, 2026 9:43pm UTC
workbench-sveltekit-workflow Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workbench-tanstack-start-workflow Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workbench-vite-workflow Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workflow-docs Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workflow-swc-playground Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workflow-tarballs Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC
workflow-web Ready Ready Preview, v0 Oct 26, 2026 9:43pm UTC

This branch was successfully deployed

1 active deployment
Preview – workflow-docs — f54f61df Deployed Oct 26, 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.

0 participants