Repository navigation
Backport #5041: fix(core): close stream reads cancelled while connecting - #5084
Open
github-actions[bot] wants to merge 1 commit into
Open
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
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 detectedLatest commit: f54f61d The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
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 |
Contributor
This branch was successfully deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Automated backport of #5041 to
stable(backport job run).AI recommendation: This is a pure resource-leak fix: cancelling a
WorkflowServerReadableStreamwhile 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 onstable(WorkflowServerReadableStreaminpackages/core/src/serialization.ts, whosecancellikewise only tears down an already-assigned#reader), and the commit is apatchchangeset plus tests with no new API surface. Note the cherry-pick needs light adaptation:stableuses a synchronousgetWorld()/world.readFromStream(name, startIndex)instead ofgetWorldLazy()/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.