Handle response for closed MVC WebSocket session - #1503
Merged
bclozel merged 1 commit intoAug 10, 2026
Merged
Conversation
Member
|
@Meemaw please sign the DCO, we cannot accept this contribution without it. |
Meemaw
force-pushed
the
gh-1501-handle-closed-session-in-response
branch
from
August 10, 2026 16:33
c423e5a to
f7e320f
Compare
Author
|
@bclozel done! |
Prior to this commit, if a WebSocket session was closed while a subscription request was still executing, response handling would fail to register the subscription with "No SessionInfo" from the doOnSubscribe callback, log the IllegalArgumentException at ERROR level as unresolved, and attempt to send an error message to the already-closed session. This commit ignores responses received after the WebSocket session state has already been removed during connection close, cancelling the response publisher instead, consistent with the inbound message handling added in spring-projectsgh-1449. Closes spring-projectsgh-1501 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Meemaw <ematej.snuderl@gmail.com>
bclozel
force-pushed
the
gh-1501-handle-closed-session-in-response
branch
from
August 10, 2026 16:49
f7e320f to
d672496
Compare
Member
|
Thanks for your contribution @Meemaw, this will be released in the next 2.0.x maintenance version in a few days. |
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.
Closes gh-1501
Follow-up to gh-1449 / #1451, which guarded the inbound message path against a session whose state has already been removed during connection close. The same race exists on the response path: if the session is closed while a
subscriberequest is still executing, thedoOnSubscribecallback inhandleResponsefails withIllegalArgumentException: No SessionInfo for ..., which is then logged at ERROR level asUnresolved IllegalArgumentException for request id <id>, and an error message send is attempted on the already-closed session.This change looks up the session state non-assertively in
handleResponseand, when the session state is already gone, cancels the response publisher instead of throwing. Cancellation (rather than an error or empty completion) is deliberate: the per-session send scheduler is disposed inafterConnectionClosed, so any terminal signal flowing through thepublishOnwould fail withRejectedExecutionException: Scheduler unavailable.The
responseAfterConnectionClosedtest holds the response back with an interceptor until afterafterConnectionClosed, and asserts the late response is silently dropped. It fails without the fix and passes with it.On a high-traffic production subscription endpoint this signature accounts for roughly 44,000 ERROR logs per 7 days, proportional to normal client disconnect churn.