If a gql_transport_ws connection ended before connection_init_timeout
asncio will warn:
(if there were no event loops after the task was closed)
Task was destroyed but it is pending!
task: <Task pending name='Task-5' coro=<BaseGraphQLTransportWSHandler.handle_connection_init_timeout() running at /home/nir/Desktop/opensource/forks/strawberry/strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py:75> wait_for=<Future pending cb=[Task.task_wakeup()]>>
Very annoying for tests.
repro:
async def test_connection_init_timeout():
client = WebsocketCommunicator(
GraphQLWSConsumer.as_asgi(
schema=schema,
# uncomment this and no warning will occure
# connection_init_wait_timeout=timedelta(seconds=0),
subscription_protocols=(GRAPHQL_TRANSPORT_WS_PROTOCOL,),
),
"/graphql",
subprotocols=[
GRAPHQL_TRANSPORT_WS_PROTOCOL,
],
)
await asyncio.sleep(0.1)
# Hope that the connection init timeout expired
res = await client.connect()
assert res == (True, GRAPHQL_TRANSPORT_WS_PROTOCOL)
data = await client.receive_output()
assert data["type"] == "websocket.close"
assert data["code"] == 4408
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too