Skip to content
Discussion options

You must be logged in to vote

This behaviour is intentional. It is up to the implementor to decide what throwing from any of the hooks, including onSubscribe, does.

When you throw there, the onMessage(callback) callback function will throw and you decide whether to close the connection or gracefully handle it (because it might be just one specific subscription failing, not needing to kick off the client complately).

In all of the built-in adapters, graphql-ws will close the connection after throwing, but it's a choice. For example, here's the use/ws adapter:

graphql-ws/src/use/ws.ts

Lines 144 to 161 in 85985ee

try {
await cb(String(event));
} catch (err) {
console.error(
'Internal error…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@devunt
Comment options

@enisdenjo
Comment options

Answer selected by devunt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #644 on May 21, 2025 11:57.