pathfinder icon indicating copy to clipboard operation
pathfinder copied to clipboard

feat(rpc): proper subscription errors

Open sistemd opened this issue 4 months ago • 0 comments

There is a problem with error reporting on websocket subscriptions. The standard gives us a mechanism to return an error before the subscription starts, but after the subscription starts (i.e. after we return the response to the starknet_subscribeXyz request), there is no mechanism to let the user know that an error occurred. Basically, once you start streaming messages to the user, there is no way to notify the user that something went wrong.

This is necessary because e.g. a lot of the subscription functionality requires us to do DB access which can always fail, or the gateway might be temporarily down or timing us out, or some other internal failure happened.

Currently the code erroneously returns a second response to the initial subscription request when an error occurs, which is totally incorrect and doesn't make sense. This PR fixes that by adding a new pathfinder_subscriptionError notification from Pathfinder to the client, which contains our standard RpcError type. This notification can be sent from all subscriptions.

If everybody agrees with this PR, we should work to get this notification renamed to starknet_subscriptionError in the near future, and have it properly introduced into the spec.

sistemd avatar Oct 10 '24 22:10 sistemd