Do subscriptions catch errors? #687
-
I'm having trouble with some of my async iterators in my subscriptions, are errors propagated in the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Can you elaborate a little more on this question, or provide an example? In pothos, a subscription field has 2 callbacks: the subscriptions can error in multiple ways, the initial function can throw an error, but it also should return an async iterator, where it can emit an error or rejected promise when the iterator is consumed. In each of these cases though, I would expect the error to be "handled", but the way the error is handled (eg closing the connection, sending a payload with an error response, etc) depends on the specifics of how the server is set up, and when/where/how the error is thrown |
Beta Was this translation helpful? Give feedback.
Can you elaborate a little more on this question, or provide an example?
In pothos, a subscription field has 2 callbacks: the
subscribe
function, and theresolve
function, both of these are passed directly to the underlying field in the generated graphql schema, so the details of how errors are handled are not controlled by pothos, but are actually handled by the graphql execution engine you are using.subscriptions can error in multiple ways, the initial function can throw an error, but it also should return an async iterator, where it can emit an error or rejected promise when the iterator is consumed. In each of these cases though, I would expect the error to be "handled", but the way …