Skip to content

Commit 354b80a

Browse files
umk0m1qkfiatjaf
authored andcommitted
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.
1 parent 0c2c2cd commit 354b80a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

abstract-relay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ export class AbstractRelay {
373373
clearInterval(this.pingIntervalHandle)
374374
this.pingIntervalHandle = undefined
375375
}
376-
this.closeAllSubscriptions('relay connection closed by us')
377376
this._connected = false
377+
this.closeAllSubscriptions('relay connection closed by us')
378378
this.idleSince = undefined
379379
this.onclose?.()
380380
if (this.ws?.readyState === this._WebSocket.OPEN) {

0 commit comments

Comments
 (0)