Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket handle function missing error handling #175

Open
WankkoRee opened this issue Mar 20, 2024 · 1 comment
Open

WebSocket handle function missing error handling #175

WankkoRee opened this issue Mar 20, 2024 · 1 comment

Comments

@WankkoRee
Copy link

solana-go/rpc/ws/client.go

Lines 171 to 184 in 790032b

func (c *Client) handleMessage(message []byte) {
// when receiving message with id. the result will be a subscription number.
// that number will be associated to all future message destine to this request
requestID, ok := getUint64WithOk(message, "id")
if ok {
subID, _ := getUint64WithOk(message, "result")
c.handleNewSubscriptionMessage(requestID, subID)
return
}
subID, _ := getUint64WithOk(message, "params", "subscription")
c.handleSubscriptionMessage(subID, message)
}

message may return error when I subscribe:

{"jsonrpc":"2.0","error":{"code":-32601,"message":"Method not found"},"id":7534392980301594513}

so we need to handle errors before getUint64WithOk(message, "result").

@Davincible
Copy link

+1 for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants