Open decentclock opened 2 years ago
The socket message from relay to app when that happens would be a first simple solution, but that would work just when the app is active and the socket is connected.
Ideally, as a long term solution, relay should have more descriptive error messages on all endpoints or defined error codes, and app should just show that error coming from relay to the user on a toast.
1. Return an error message with the response to the API call that triggers the routing in the first place. 2. Add a socket message from relay to the app that is sent upon routing failures such as the one above.
Should we maybe get a socket message out first and then also have there be an error response as well in the future?
I can start looking into how to get a socket message for this setup
seems like this is where that error is being thrown
https://github.com/stakwork/sphinx-relay/blob/master/src/network/send.ts#L205
@tomastiminskas how are we handling 400
errors right now? do we tost the error
field if success
is false
?
seems like this is where that error is being thrown
https://github.com/stakwork/sphinx-relay/blob/master/src/network/send.ts#L205
ya theres a "failure" callback so the higher level function can pass back the error https://github.com/stakwork/sphinx-relay/blob/master/src/network/send.ts#L211
So for example for sending a simple text message, we need to add a "success" and "failure" functions here https://github.com/stakwork/sphinx-relay/blob/master/src/controllers/messages.ts#L363. The complicated part is that in tribes, "sendMessage" can actually send a bunch of messages, that can both be over MQTT and over Lightning
@kevkevinpal sorry I missed this. So the app just shows a yellow/red bolt in dashboard if any request returns a code other than 200. And at the moment the endpoint returns failure we are on most of the cases showing a generic error alert like:
"action
failed, please try again later"
If relay starts returning descriptive error message on each endpoint the app can start showing the error coming from relay to the user. Then giving support to users when something is failing will be much easier since we will know the cause of the problem.
In addition, If socket message is implemented I can easily show a toast or alert with the message coming from relay through socket. Each socket message has a type (we can create a new type error
and then inside the response send a message
that will be directly shown to the user.
So for anyone taking up this issue a good example to look at is to learn how we use websockets is for when relay receives a message
Here the correct function is being called when we get the message https://github.com/stakwork/sphinx-relay/blob/master/src/controllers/index.ts#L178
The socket io message being sent in that above function https://github.com/stakwork/sphinx-relay/blob/master/src/controllers/messages.ts#L462=
and we'd want to do something similar for errors right @tomastiminskas maybe a
socket.sendJson(
{
type: 'error',
response: jsonUtils.errorToJson(...),
},
tenant
)
I think we can return the error directly as the result of the endpoint that sent the message
In fact the errorMessage
should be stored directly on the Message table itself, so you can see the errors after the fact as well
Currently, when sphinx relay gets back a routing error from its RPC interface to the node, the app does not get notified of this failure.
An example of the RPC error returned from the node:
I had a chat with @tomastiminskas, and he believes there are two options:
Let me know if you have any questions / need any clarifications.