mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2026-02-12 10:54:33 +00:00
fix(relay): move _connected = false above closeAllSubscriptions() in close()
close() was setting _connected = false after closeAllSubscriptions(), which meant each sub still saw the relay as connected and tried to send CLOSE frames. Those sends get queued as microtasks, but by the time they run the socket is already closing, so you get a bunch of "WebSocket is already in CLOSING or CLOSED state" warnings. handleHardClose() already gets this order right — this just makes close() consistent with that.
This commit is contained in:
@@ -373,8 +373,8 @@ export class AbstractRelay {
|
||||
clearInterval(this.pingIntervalHandle)
|
||||
this.pingIntervalHandle = undefined
|
||||
}
|
||||
this.closeAllSubscriptions('relay connection closed by us')
|
||||
this._connected = false
|
||||
this.closeAllSubscriptions('relay connection closed by us')
|
||||
this.idleSince = undefined
|
||||
this.onclose?.()
|
||||
if (this.ws?.readyState === this._WebSocket.OPEN) {
|
||||
|
||||
Reference in New Issue
Block a user