-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebFlux may send incomplete response if the session persistence fails #24186
Comments
I can confirm there is an issue. The session persistence failure happens at an inconvenient time, after the response is committed and the |
This should be fixed in the latest 5.2.3 snapshots. I've verified with code similar to the snippets above. |
@rstoyanchev is it possible to customize an error response which is generated as a result of a before commit chain failure? Now if session.save fails (because the session store exceeds the predefined size) user invariably receives 500 response. For this particular situation I would prefer 503, but it seems WebExceptionHandlers are never activated. ...
exchange.getResponse()
.beforeCommit(() -> Mono.defer(session::save)
.onErrorResume(this::isMaxSessionsLimitReachedException, e -> {
exchange.getResponse().setStatusCode(HttpStatus.SERVICE_UNAVAILABLE);
exchange.getResponse().getHeaders().clear();
exchange.getResponse().getCookies().clear();
return Mono.empty();
}));
... (however it doesn't give me a chance to provide a body otherwise the client hangs). Your expertise would be valued. Thanks! |
@evgenyvsmirnov from what I can see a I think we can introduce an additional state to remember that a pre-commit action failed. Then if the error is handled, on the second attempt to commit, if the response contains an error code and we know a pr-commit action failed, we can proceed straight to updating the response. In addition we could also have Can you open a separate issue for this? |
@rstoyanchev , thank you for a swift reply. Have created the issue: #25753 |
Components and interactions
Please have a look at the following test. It contains:
WebSessionController:
WebSessionTestWebSessionManager:
WebSessionTest:
pom.xml:
Expected result
Client gets 4xx/5xx response or at least ends up with the closed connection caused by exceeded concurrent sessions limit number.
Actual result
Client hangs.
Additional information
If I suspend the test with the IDE debugger (it blocks the test thread only) and send a request via curl I see the following output:
Here "Content-Length: 7" is the length of 200 response (the contents of the URI's last segment) which WebSessionController sends, so the status line and the headers have been sent but the body hasn't. It looks like if the server had sent the status line and the headers with an exception occurred afterwards which resulted in the inability to send error response.
Environment:
The text was updated successfully, but these errors were encountered: