You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the error handling for subscription events is not
well-defined in the GraphQL spec, but that doesn't mean we shouldn't
handle them! The existing behavior is that an error thrown from a
subscription's generator will go uncaught and crash the whole server.
For a transient failure, it may be preferable for consumers that we
simply return an error response and continue waiting for more data from
the iterator, in case the producer recovers and resumes producing valid
data. However, Node's AsyncGenerator terminates once an error is thrown,
even if you manually loop calling `iterator.next()`.
This change wraps the iterator consumption in a `try/catch` and closes
the subscription when an error is encountered. Propagating the error up
to the subscriber will allow them to decide if they need to resubscribe
or not, in the case of a transient error.
0 commit comments