Skip to content

Commit

Permalink
fix: handle gracefuly case when trying to subscribe to accounts notif…
Browse files Browse the repository at this point in the history
…ications and WS connection is not open
  • Loading branch information
thaaddeus committed Dec 22, 2021
1 parent 96523af commit e76ca5c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/rpc_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,13 @@ class AccountsChangeNotifications {
private _subscribeToAccountsNotifications(ws: WebSocket) {
for (const meta of this._accountsMeta) {
if (ws.readyState !== ws.OPEN) {
throw new Error('_subscribeToAccountsNotifications WS closed')
logger.log('info', 'Failed to subscribe to accounts notifications', {
market: this._options.marketName,
wsState: ws.readyState
})

this._restartConnection()
return
}
this._sendMessage(ws, {
jsonrpc: '2.0',
Expand Down

0 comments on commit e76ca5c

Please sign in to comment.