Skip to content

Commit

Permalink
Catch exception on failed WS command to avoid interface from breaking (
Browse files Browse the repository at this point in the history
…mattermost-community#3858)

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

* Fix linter
  • Loading branch information
mgdelacroix authored Sep 16, 2022
1 parent 8ded583 commit 68f03d3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions webapp/src/wsclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 68f03d3

Please sign in to comment.