Skip to content

fix: complete WebSocket upgrade result when the handshake is cancelled - #1672

Open
He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:fix/websocket-complete-upgrade-on-handshake-cancellation
Open

He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:fix/websocket-complete-upgrade-on-handshake-cancellation

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 26, 2026

Copy link
Copy Markdown
Member

Motivation

When cancellation reaches the client opening-handshake stage, the materialized upgrade result could stay pending if the opening timeout was disabled.

Modification

Settle the pending result when the handshake stage receives downstream cancellation, regardless of its opening deadline. Preserve the original failure and any result already completed. Cover cancellation before and after request dispatch and document the behavior.

Result

A cancelled opening handshake completes its upgrade result exceptionally under both finite and disabled timeouts. This does not change the established message stream's half-close behavior, normal upgrade and rejection handling, or upstream EOF handling.

Tests

  • JDK 17, Scala 2.13.18 and 3.3.9: eight focused native WebSocket cases passed on each version. The new default-timeout case failed on the unfixed baseline as expected.
  • Scoped Scalafmt and header checks passed. The final Paradox docs build passed.

References

Motivation:
An opening handshake cancellation could leave the materialized upgrade result pending when the opening timeout was disabled.

Modification:
Settle a still-pending upgrade result when cancellation reaches the handshake stage, independent of the opening deadline. Cover cancellation before and after request dispatch and document the behavior.

Result:
Cancellation completes the upgrade result exceptionally without changing already completed outcomes, peer EOF handling, or the API.

References:
Apache Pekko HTTP apache#1461 and apache#1549; RFC 6455 Section 4.1 for the opening handshake.
@He-Pin
He-Pin requested a review from pjfanning November 26, 2026 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant