From 354b80a929415dc3fb429a32bd51c6613b393bc5 Mon Sep 17 00:00:00 2001 From: umk0m1qk <158820607+umk0m1qk@users.noreply.github.com> Date: Wed, 11 Feb 2026 19:05:49 +0500 Subject: [PATCH] fix(relay): move _connected = false above closeAllSubscriptions() in close() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- abstract-relay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abstract-relay.ts b/abstract-relay.ts index bc598c6..4b744f9 100644 --- a/abstract-relay.ts +++ b/abstract-relay.ts @@ -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) {