From 4fffcaca6688fa7aedc3c5168c7da9bf4024f336 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Tue, 6 Oct 2026 21:47:06 -0500 Subject: [PATCH 1/2] fix(logger): stop recursing when a failed send cannot be reported When sending to the logger isolate fails, log() reports it through t(), which sends again. If the port is gone every send fails, so log -> t -> log recursed until the stack overflowed. Report the failure once; if that fails too, print the original entry and the error instead. --- lib/utilities/logger.dart | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/utilities/logger.dart b/lib/utilities/logger.dart index b0b37cd55e..05234d1b38 100644 --- a/lib/utilities/logger.dart +++ b/lib/utilities/logger.dart @@ -29,6 +29,8 @@ class Logging { late final String logsDirPath; + bool _reportingSendFailure = false; + SendPort get _sendPort { final port = IsolateNameServer.lookupPortByName(_kLoggerPortName); if (port == null) { @@ -151,7 +153,26 @@ class Logging { toFile, )); } catch (e, s) { - t("Isolates suck", error: e, stackTrace: s); + // If reporting a failed send fails as well (e.g. the logger isolate + // is gone), let the outer call print instead of logging again, which + // would recurse until the stack overflows. + if (_reportingSendFailure) rethrow; + _reportingSendFailure = true; + try { + t("Isolates suck", error: e, stackTrace: s); + } catch (_) { + try { + // ignore: avoid_print + print( + "${level.name} [$time] $message" + ", ERROR: $error" + ", STRACE: $stackTrace" + ", LOGGING FAILED: $e", + ); + } catch (_) {} + } finally { + _reportingSendFailure = false; + } } } From 2e675d968d81dd4628b05485e6c3721f587ac4c8 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 7 Oct 2026 13:10:36 -0500 Subject: [PATCH 2/2] fix(logger): report send failures directly to the console --- lib/utilities/logger.dart | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/lib/utilities/logger.dart b/lib/utilities/logger.dart index 05234d1b38..8490a2ec4f 100644 --- a/lib/utilities/logger.dart +++ b/lib/utilities/logger.dart @@ -29,8 +29,6 @@ class Logging { late final String logsDirPath; - bool _reportingSendFailure = false; - SendPort get _sendPort { final port = IsolateNameServer.lookupPortByName(_kLoggerPortName); if (port == null) { @@ -152,27 +150,16 @@ class Logging { ), toFile, )); - } catch (e, s) { - // If reporting a failed send fails as well (e.g. the logger isolate - // is gone), let the outer call print instead of logging again, which - // would recurse until the stack overflows. - if (_reportingSendFailure) rethrow; - _reportingSendFailure = true; + } catch (e) { try { - t("Isolates suck", error: e, stackTrace: s); - } catch (_) { - try { - // ignore: avoid_print - print( - "${level.name} [$time] $message" - ", ERROR: $error" - ", STRACE: $stackTrace" - ", LOGGING FAILED: $e", - ); - } catch (_) {} - } finally { - _reportingSendFailure = false; - } + // ignore: avoid_print + print( + "${level.name} [$time] $message" + ", ERROR: $error" + ", STRACE: $stackTrace" + ", LOGGING FAILED: $e", + ); + } catch (_) {} } }