Skip to content

Commit

Permalink
fix: throw when initial websocket connection times out
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger committed Sep 11, 2024
1 parent b4c265c commit 30ed519
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,15 @@ export class WmClient {
* @private
*/
private async _waitForConnection(): Promise<WebSocket> {
if (this._socket && this._socket.readyState === this._socket.OPEN) {
if (
!this._socket ||
this._socket.readyState === this._socket.CLOSED ||
this._socket.readyState === this._socket.CLOSING
) {
throw new Error('Websocket connection is closed.');
}

if (this._socket.readyState === this._socket.OPEN) {
return this._socket;
}

Expand Down

0 comments on commit 30ed519

Please sign in to comment.