Repository navigation
Conversation
Some servers (Hasura being a known example) emit keep-alive messages before the connection ack. The handshake took the first received message and threw if it was not the ack, aborting the connection. Skip anything that is not the ack and keep waiting for it, still bounded by the acknowledgement timeout. A connection error is not skipped: it fails the handshake right away with the server's payload.
goingforstudying-ctrl
requested review from
asibross,
iparadiso,
iuliiasobolevska,
jjacobs44,
kilink,
kzwang,
paulbakker and
srinivasankavitha
as code owners
August 27, 2026 05:50
jjacobs44
approved these changes
Sep 1, 2026
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 #1328
What
Per the subscriptions-transport-ws protocol the server answers
connection_initwithconnection_ack, but some servers emit other messages first. Hasura, for example, sends aka(keep-alive) immediately after connecting (hasura/graphql-engine#7002).WebSocketGraphQLClient.doHandshake()takes the first message off the wire and throws if it isn't the ack, so any subscription against such a server fails during the handshake:Fix
The handshake now keeps waiting for the ack and skips anything else that arrives first, logging skipped messages at debug level, still bounded by the same acknowledgement timeout.
One case is not skipped:
connection_error. It means the server rejected theconnection_init, so the handshake now fails right away with the server's payload instead of sitting behind the timeout.Added
requires org.slf4jto the module descriptor for the new debug logging (slf4j-api was already on the compile classpath).Tests
Updated
WebSocketGraphQLClientTest:skipsKeepAliveMessageBeforeAck— the Hasura case from bug: WebSocketGraphQLClient handshake fails if it receives a keep alive message before connection ack #1328:kathenack, the subscription proceeds and receives dataskipsStrayDataMessageBeforeAck— a data message before the ack is ignored rather than fatal (no subscription exists yet at that point, so it can't belong to this client)errorsOnConnectionErrorBeforeAck—connection_errorstill fails the handshake fastThe previous
errorsIfMessageOtherThanAckFromServertest asserted the strict behavior the issue asks to change, so it is replaced by the tests above.timesOutIfNoAckFromServeris unchanged and still passes: with no ack at all, the handshake times out as before.Both new skip tests fail against the current implementation, and the full
:graphql-dgs-client:testsuite passes with the fix.