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

Compatibility with graphql-ws keepAlive #851

Closed
andreialecu opened this issue Aug 27, 2022 · 4 comments · Fixed by #852
Closed

Compatibility with graphql-ws keepAlive #851

andreialecu opened this issue Aug 27, 2022 · 4 comments · Fixed by #852
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@andreialecu
Copy link
Contributor

I'm experimenting with switching from Apollo Express to Fastify and Mercurius.

I discovered something a bit weird. If I enable keepAlive in graphql-ws, it will send messages that look like {"type": "ping"} but it seems that something on the Mercurius side is not processing them correctly.

Screenshot 2022-08-27 at 17 50 32

On the other hand, If I enable keepAlive in Mercurius, it sends messages like {type: "ka"}:
Screenshot 2022-08-27 at 17 52 03

graphql-ws completely crashes on these messages and breaks the subscription:
Screenshot 2022-08-27 at 17 52 38

My understanding is that Mercurius uses graphql-ws, so what's the deal here? 🙂

@mcollina
Copy link
Collaborator

I think there is a bug somewhere in Mercurius that requires the payload in https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md#ping to exist.

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@mcollina mcollina added bug Something isn't working good first issue Good for newcomers labels Aug 27, 2022
@andreialecu
Copy link
Contributor Author

andreialecu commented Aug 27, 2022

I'll take a look at submitting a PR for this. I believe this is also incorrect:

GQL_CONNECTION_KEEP_ALIVE: 'ka', // Server -> Client

I don't think graphql-ws understands the ka message, based on the error in my original report.

Instead it should probably be pong.

@mcollina
Copy link
Collaborator

note that you should only change the graphql-transport-ws subprotocol.

@andreialecu
Copy link
Contributor Author

Opened #852

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants