Closed Sytten closed 2 years ago
I am experiencing this as well. Our entire application communicates via websockets using this transport, and I would like to be able to give detailed error reporting to our sentry integration via a plugin. However, I can not currently as none of our requests trigger off the proper hooks. If I knew where to start, I would take a crack at fixing this myself. Thanks!
Since the subs module is "independent" from the apollo server, it has no notion of the hooks and the lifecycle. It only has the interface for the formatError (https://github.com/apollographql/subscriptions-transport-ws/blob/master/src/server.ts#L30). Like I said many times, this feels like abandoned software which I don't understand since Subscriptions are quite a big part of GraphQL.
But looking at the roadmap for apolo server v3, it says Removal of subscription-transport-ws in favor of a built-in solution that takes full advantage of the main request pipeline
. So I don't think we will have much progress here.
@Sytten Thanks for finding that! Just going to have to wait till the officially integrated websocket transport into the apollo server I guess. I was really hoping to get more detailed errors logging properly. Thanks!
@michaelsharpe No worries, what I did in the meantime is wrap the resolve part of the subscriptions in an error handler that catches the errors and report them. Not ideal but it works.
@Sytten Hi, nice to hear someone being quite clear about this issue. I'm looking at instrumenting subscriptions, do you have any recommendations for wrapping them?
Not really since we use the nexus schema library I just created a new subscriptionField method that wraps the resolve method in a try-catch and report errors.
Reposting my original issue here since it is more relevant to this repo.
When using subscriptions, the server does not currently trigger the hooks of the installed plugins for an Apollo server. This means that if I user decided to handle errors in
didEncounterErrors
for example, it will completely bypass it and the user might never be alerted of errors in production (It does however callformatError
).