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:
umk0m1qk
2026-02-11 19:05:49 +05:00
committed by fiatjaf_
parent 0c2c2cd4d8
commit 354b80a929

View File

@@ -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) {