Skip to content

Commit

Permalink
Only reconnect socket if not disposed
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Oct 21, 2024
1 parent 1c77e21 commit 0c7800c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/src/network/socket.dart
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,14 @@ class SocketClient {
_reconnectTimer?.cancel();
_reconnectTimer = Timer(delay, () {
_averageLag.value = Duration.zero;
_logger.fine('Reconnecting WebSocket.');
connect();
if (!isDisposed) {
_logger.fine('Reconnecting WebSocket.');
connect();
} else {
_logger.warning(
'Scheduled reconnect after $delay failed since client is disposed.',
);
}
});
}

Expand Down

0 comments on commit 0c7800c

Please sign in to comment.