Skip to content

Commit

Permalink
Fix properly exiting the WebsocketsTransport when a connection_error …
Browse files Browse the repository at this point in the history
…is received during init (#486)
  • Loading branch information
leszekhanusz authored Jul 14, 2024
1 parent 8c33e8f commit 9f93215
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gql/transport/websockets_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,11 @@ async def connect(self) -> None:
await self._initialize()
except ConnectionClosed as e:
raise e
except (TransportProtocolError, asyncio.TimeoutError) as e:
except (
TransportProtocolError,
TransportServerError,
asyncio.TimeoutError,
) as e:
await self._fail(e, clean_close=False)
raise e

Expand Down
3 changes: 3 additions & 0 deletions tests/test_websocket_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ async def test_websocket_connect_failed_with_authentication_in_connection_init(

await session.execute(query1)

await asyncio.sleep(1)
assert transport.websocket is None


@pytest.mark.parametrize("server", [server1_answers], indirect=True)
def test_websocket_execute_sync(server):
Expand Down

0 comments on commit 9f93215

Please sign in to comment.