fix: close replayed request SSE streams when no request remains in flight - #2779
Open
ashwinmridul wants to merge 1 commit into
Open
Conversation
…ight After Last-Event-ID replay, keep-alive was holding the successor stream open even when the correlated request had already retired, so a later reconnect could be refused with 409. Close and unregister per-request streams in that case; leave the standalone GET stream open. Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: 3b11713 The changes in this PR will be included in the next version bump. 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 |
commit: |
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.
Fixes #2558 (v1.x backport of the original close-after-replay slice).
Summary
On
main, aLast-Event-IDresume of a per-request SSE stream already closes and unregisters that stream when no in-flight request still maps to it.v1.xstill armed keep-alive on that successor, so resume polling could hang open and a later reconnect withgetStreamIdForEventIdcould be refused with 409.This PR ports that behavior:
_requestToStreamMappinghas no remaining request for it, close the controller and drop the mapping._GET_streamis unchanged.I am not taking the widened
Exchangestate-machine scope from the later issue comment; that belongs onmainfirst. This is the original close-when-idle replay fix for the v1 line.Tests
closeSSEStream+ retired request replays the stored result, then a second reconnect is 200 (not 409)._GET_stream, which is the stream that should stay open.npx vitest run test/server/streamableHttp.test.ts: 188 passed.Note on #2677
I am not opening a third PR for the draft-07
$schemabug. #2085 and #2653 already fix it onv1.x.