Catch exception on failed WS command to avoid interface from breaking (#3858)

* Catch exception on failed WS command to avoid interface from breaking

* Fix linter
This commit is contained in:
Miguel de la Cruz 2022-09-16 13:21:36 +02:00 committed by GitHub
parent 8ded5838a8
commit 68f03d3fb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -172,13 +172,17 @@ class WSClient {
}
sendCommand(command: WSCommand): void {
if (this.client !== null) {
const {action, ...data} = command
this.client.sendMessage(this.clientPrefix + action, data)
return
}
try {
if (this.client !== null) {
const {action, ...data} = command
this.client.sendMessage(this.clientPrefix + action, data)
return
}
this.ws?.send(JSON.stringify(command))
this.ws?.send(JSON.stringify(command))
} catch (e) {
Utils.logError(`WSClient failed to send command ${command.action}: ${e}`)
}
}
sendAuthenticationCommand(token: string): void {