Remove listeners from sockets on disconnect

This commit is contained in:
Jonathan Staab
2023-08-02 11:45:15 -07:00
parent ef18009d33
commit 9dad35ce20
3 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ export class Executor {
},
}
}
publish(event, {verb = 'EVENT', onOk, onError}) {
publish(event, {verb = 'EVENT', onOk, onError} = {}) {
const okListener = (url, id, ...payload) => id === event.id && onOk(url, id, ...payload)
const errorListener = (url, id, ...payload) => id === event.id && onError(url, id, ...payload)
+1
View File
@@ -75,6 +75,7 @@ export class Socket extends EventEmitter {
// Avoid "WebSocket was closed before the connection was established"
this.ready.then(() => ws.close(), () => null)
this.ws.removeAllListeners()
this.ws = undefined
}
}