Handle socket errors

This commit is contained in:
Jon Staab
2024-05-22 12:56:54 -07:00
parent fdce131d27
commit d5b4a3218e
8 changed files with 18 additions and 13 deletions
+2 -1
View File
@@ -59,6 +59,7 @@ export class Socket {
}
onError = () => {
this.failedToConnect = true
this.opts.onError()
this.disconnect()
}
@@ -105,7 +106,7 @@ export class Socket {
if (this.ws) {
const currentWs = this.ws
this.ready.then(() => currentWs.close())
this.ready.finally(() => currentWs.close())
this.ready = defer()
this.opts.onClose()
this.ws = undefined