fix: set demangleStackTrace to handle async chain stack traces
When zone errors bubble up through Dart's async machinery the stack trace is in package:stack_trace chain format (with '===== asynchronous gap =====' separators). Flutter's StackFrame parser asserts on those lines. FlutterError.demangleStackTrace strips the chain format back to a plain VM trace before Flutter tries to parse it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
1aa2926f30
commit
ef3255cd2b
@@ -12,6 +12,7 @@ import 'package:sharedinbox/data/db/database.dart';
|
||||
import 'package:sharedinbox/di.dart';
|
||||
import 'package:sharedinbox/ui/router.dart';
|
||||
import 'package:sharedinbox/ui/screens/crash_screen.dart';
|
||||
import 'package:stack_trace/stack_trace.dart' as stack_trace;
|
||||
|
||||
void main({List<Override> overrides = const []}) {
|
||||
unawaited(
|
||||
@@ -19,6 +20,15 @@ void main({List<Override> overrides = const []}) {
|
||||
() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// Dart's async machinery propagates stack traces in chain format
|
||||
// (with '===== asynchronous gap =====' separators). Flutter's
|
||||
// StackFrame parser asserts on those lines, so strip them first.
|
||||
FlutterError.demangleStackTrace = (StackTrace s) {
|
||||
if (s is stack_trace.Chain) return s.toTrace().vmTrace;
|
||||
if (s is stack_trace.Trace) return s.vmTrace;
|
||||
return s;
|
||||
};
|
||||
|
||||
// Catch errors during build (e.g. layout exceptions) and show CrashScreen.
|
||||
ErrorWidget.builder = (details) => CrashScreen(
|
||||
exception: details.exception,
|
||||
|
||||
+1
-1
@@ -1021,7 +1021,7 @@ packages:
|
||||
source: hosted
|
||||
version: "0.44.4"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: stack_trace
|
||||
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
|
||||
|
||||
@@ -58,6 +58,9 @@ dependencies:
|
||||
flutter_local_notifications: ^21.0.0
|
||||
workmanager: ^0.9.0
|
||||
|
||||
# Stack trace chain-to-VM conversion for FlutterError.demangleStackTrace
|
||||
stack_trace: ^1.12.1
|
||||
|
||||
# App version metadata for crash reports
|
||||
package_info_plus: ^10.1.0
|
||||
share_plus: ^13.1.0
|
||||
|
||||
Reference in New Issue
Block a user