Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError for specific websocket connection init timeout #1217

Open
Kwaidan00 opened this issue Jan 30, 2025 · 0 comments
Open

RuntimeError for specific websocket connection init timeout #1217

Kwaidan00 opened this issue Jan 30, 2025 · 0 comments

Comments

@Kwaidan00
Copy link
Contributor

Let's consider the following code:

GraphQLTransportWSHandler(connection_init_wait_timeout=timedelta(minutes=0))

which is used in the Ariadne's test suite.

After the changes of the test client implementation introduced in Starlette 0.45.1 (https://github.com/encode/starlette/releases/tag/0.45.1), the following test fails every time:

FAILED tests/asgi/test_configuration.py::test_init_wait_timeout_graphql_transport_ws - RuntimeError: Cannot call "send" once a close message has been sent.

However, I don't think the failing test is caused by Starlette changes. It could just reveal an issue that existed before. I tried to run https://github.com/mirumee/ariadne-graphql-chat-example with the 0 timeout, I could see this RuntimeError as well. I double-checked it for both older and newest Starlette.

The problematic code lives in

timeout_handler = self.handle_connection_init_timeout(websocket, client_context)
client_context.connection_init_timeout_task = asyncio.create_task(
timeout_handler
)
await websocket.accept("graphql-transport-ws")
- the timeout handler task closes the connection, but after that accept is called.

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

No branches or pull requests

1 participant