Skip to content

Conversation

@lachlan-roberts
Copy link
Contributor

closes #13465

… called twice

Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
@joakime joakime moved this to 👀 In review in Jetty 12.1.1 - FROZEN Aug 20, 2025
Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lachlan-roberts yes it should also fix #13466.

The fix should be less flaky, so the test failures should be investigated.

@lachlan-roberts
Copy link
Contributor Author

@sbordet I have investigated the failures.

In the test the client is trying to upgrade to websocket over HTTP/2 and the server is throwing an exception in the websocket creator.

When the client sends the headers frame to upgrade it does not include an END_STREAM flag because the subsequent data frames it sends will be websocket bytes.

The server sees the exception and tries to send a 500 response, it sends a HEADERS frame with the END_STREAM flag.
But the server sees that the client has not sent an END_STREAM flag so it resets the stream.

The client then has a race whether it processes the HEADERS frame with the 500 response, or the RST_STREAM frame first.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet
Copy link
Contributor

sbordet commented Aug 30, 2025

@lachlan-roberts I fixed the tests, please review the fix.

The build failed due to #13533, so I think this PR is fine now.

@lachlan-roberts
Copy link
Contributor Author

@sbordet it seems after merging with 12.1.x it still has the same failures.
CI shows the Stream has been reset failure is still there in WebSocketOverHTTP2Test.

Now testing whether the request was a tunnel, and if so, try to close the request side of the stream.
If the close is successful, it means a response was already sent, so we can avoid sending a RST_STREAM.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet linked an issue Sep 3, 2025 that may be closed by this pull request
… tunnel.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@lachlan-roberts lachlan-roberts merged commit f880653 into jetty-12.1.x Sep 4, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Jetty 12.1.1 - FROZEN Sep 4, 2025
@lachlan-roberts lachlan-roberts deleted the jetty-12.1.x-13465-WebSocketClientResponseListener branch September 4, 2025 05:10
sbordet added a commit that referenced this pull request Sep 5, 2025
This PR is an addendum to #13486, that improves the handling of WebSocket upgrade failures.

If there was a failure in the HTTP upgrade, it is now retained and handled as-is, not converted to an UpgradeException.
This should ensure better backward compatibility with 12.0.x.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
olamy pushed a commit that referenced this pull request Sep 8, 2025
* Fixes #13466 - Lost WebSocket upgrade failure.

This PR is an addendum to #13486, that improves the handling of WebSocket upgrade failures.

If there was a failure in the HTTP upgrade, it is now retained and handled as-is, not converted to an UpgradeException.
This should ensure better backward compatibility with 12.0.x.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>

* Fixed test expectations.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>

---------

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Lost WebSocket upgrade failure Review invocation of UpgradeListener.onHandshakeResponse() in case of failures

3 participants