From 387f6cf27360c9092b5414742eb25588fb11047f Mon Sep 17 00:00:00 2001 From: wenzuhuai Date: Thu, 22 Jan 2026 09:18:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=97=AD=E5=8C=85?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=B7=B7=E7=94=A8=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Nats/NatsConnection.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/Nats/NatsConnection.swift b/Sources/Nats/NatsConnection.swift index bbb6457..1bc4e8a 100644 --- a/Sources/Nats/NatsConnection.swift +++ b/Sources/Nats/NatsConnection.swift @@ -937,7 +937,6 @@ class ConnectionHandler: ChannelInboundHandler { if currentState == .disconnected || currentState == .closed { return false // Already in disconnected/closed state } - $0 = .disconnected return true } @@ -945,6 +944,9 @@ class ConnectionHandler: ChannelInboundHandler { return } + // Set state to disconnected after check + state.withLockedValue { $0 = .disconnected } + // Clean up pending continuations to prevent leaks if let continuation = serverInfoContinuation.withLockedValue({ cont in let toResume = cont