fix: error thrown on ws close

This commit is contained in:
Jeffrey Ko 2024-03-16 19:48:24 +08:00 committed by fiatjaf_
parent 71456feb20
commit e1bde08ff3
1 changed files with 2 additions and 2 deletions

View File

@ -78,9 +78,9 @@ export class AbstractRelay {
this.connectionPromise = new Promise((resolve, reject) => {
this.connectionTimeoutHandle = setTimeout(() => {
reject('connection timed out')
this.connectionPromise = undefined
this.onclose?.()
this.closeAllSubscriptions('relay connection timed out')
this.connectionPromise = undefined
}, this.connectionTimeout)
try {
@ -106,9 +106,9 @@ export class AbstractRelay {
}
this.ws.onclose = async () => {
this.connectionPromise = undefined
this.onclose?.()
this.closeAllSubscriptions('relay connection closed')
this.connectionPromise = undefined
this._connected = false
}