From 7203465b18f4bc046a43c2e6be0bca300c5e4886 Mon Sep 17 00:00:00 2001 From: matehat Date: Mon, 29 Sep 2025 20:58:34 -0400 Subject: [PATCH] fix 1825: wrap decoding in try/catch --- pkgs/cupertino_http/lib/src/cupertino_web_socket.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/cupertino_http/lib/src/cupertino_web_socket.dart b/pkgs/cupertino_http/lib/src/cupertino_web_socket.dart index 5198b7bb17..080e3c12c8 100644 --- a/pkgs/cupertino_http/lib/src/cupertino_web_socket.dart +++ b/pkgs/cupertino_http/lib/src/cupertino_web_socket.dart @@ -203,7 +203,13 @@ class CupertinoWebSocket implements WebSocket { void _connectionClosed(int? closeCode, objc.NSData? reason) { if (!_events.isClosed) { - final closeReason = reason == null ? '' : utf8.decode(reason.toList()); + String closeReason; + + try { + closeReason = reason == null ? '' : utf8.decode(reason.toList()); + } on FormatException { + closeReason = 'unknown'; + } _events ..add(CloseReceived(closeCode, closeReason))