From 929c1c3d286664d1d65301b1f9cb985a3edaafd1 Mon Sep 17 00:00:00 2001 From: just-stuff-tm Date: Mon, 9 Mar 2026 20:39:17 -0400 Subject: [PATCH] `fix(tcp): cancel pending connects on disconnect and propagate remote close` --- lib/connector/meshcore_connector_tcp.dart | 3 --- lib/services/tcp_transport_service_native.dart | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/connector/meshcore_connector_tcp.dart b/lib/connector/meshcore_connector_tcp.dart index 01c2b92..92b98d7 100644 --- a/lib/connector/meshcore_connector_tcp.dart +++ b/lib/connector/meshcore_connector_tcp.dart @@ -22,9 +22,6 @@ class MeshCoreTcpManager { } Future disconnect() async { - if (!_service.isConnected && _service.activeEndpoint == null) { - return; - } _debugLog?.info('TcpManager.disconnect', tag: 'TCP'); await _service.disconnect(); } diff --git a/lib/services/tcp_transport_service_native.dart b/lib/services/tcp_transport_service_native.dart index d8a3ab3..a6db99b 100644 --- a/lib/services/tcp_transport_service_native.dart +++ b/lib/services/tcp_transport_service_native.dart @@ -175,6 +175,11 @@ class TcpTransportService { } void _handleSocketDone() { + if (_status == TcpTransportStatus.disconnecting || + _status == TcpTransportStatus.disconnected) { + return; + } + _addFrameError(StateError('TCP socket closed by remote endpoint')); unawaited(disconnect()); }