Skip to content

Commit 374c7b8

Browse files
committed
fix(logger): avoid infinite recursion when isolate log port fails
1 parent 51db6c7 commit 374c7b8

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

lib/utilities/logger.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import 'dart:convert';
1212
import 'dart:core' as core;
1313
import 'dart:core';
14+
import 'dart:io';
1415
import 'dart:isolate';
1516
import 'dart:ui';
1617

@@ -150,8 +151,16 @@ class Logging {
150151
),
151152
toFile,
152153
));
153-
} catch (e, s) {
154-
t("Isolates suck", error: e, stackTrace: s);
154+
} catch (dispatchError, dispatchStackTrace) {
155+
final originalMessage = _stringifyMessage(message);
156+
final fallbackLines = <String>[
157+
"[logging-fallback:$level] $originalMessage",
158+
"dispatchError: $dispatchError",
159+
if (error != null) "error: $error",
160+
if (stackTrace != null) "stackTrace: $stackTrace",
161+
"dispatchStackTrace: $dispatchStackTrace",
162+
];
163+
stderr.writeln(fallbackLines.join("\n"));
155164
}
156165
}
157166

0 commit comments

Comments
 (0)