diff --git a/packages/flutter_tools/lib/runner.dart b/packages/flutter_tools/lib/runner.dart index 11346a3c436..c9349d82d59 100644 --- a/packages/flutter_tools/lib/runner.dart +++ b/packages/flutter_tools/lib/runner.dart @@ -64,7 +64,7 @@ Future run( flutterVersion ?? globals.flutterVersion.getVersionString(redactUnknownBranches: true); Object? firstError; StackTrace? firstStackTrace; - return runZoned>( + return runZonedGuarded>( () async { try { if (args.contains('--disable-analytics') && args.contains('--enable-analytics')) { @@ -122,7 +122,7 @@ Future run( ); } }, - onError: (Object error, StackTrace stackTrace) async { + (Object error, StackTrace stackTrace) async { // If sending a crash report throws an error into the zone, we don't want // to re-try sending the crash report with *that* error. Rather, we want // to send the original error that triggered the crash report. @@ -138,7 +138,7 @@ Future run( shutdownHooks, ); }, - ); + )!; }, overrides: overrides); } diff --git a/packages/flutter_tools/lib/src/base/async_guard.dart b/packages/flutter_tools/lib/src/base/async_guard.dart index 6bf346e96fe..5e376683e39 100644 --- a/packages/flutter_tools/lib/src/base/async_guard.dart +++ b/packages/flutter_tools/lib/src/base/async_guard.dart @@ -103,24 +103,19 @@ Future asyncGuard(Future Function() fn, {Function? onError}) { } } - runZoned( - () async { - try { - final T result = await fn(); - if (!completer.isCompleted) { - completer.complete(result); - } - // This catches all exceptions so that they can be propagated to the - // caller-supplied error handling or the completer. - // ignore: avoid_catches_without_on_clauses, forwards to Future - } catch (e, s) { - handleError(e, s); + runZonedGuarded(() async { + try { + final T result = await fn(); + if (!completer.isCompleted) { + completer.complete(result); } - }, - onError: (Object e, StackTrace s) { + // This catches all exceptions so that they can be propagated to the + // caller-supplied error handling or the completer. + // ignore: avoid_catches_without_on_clauses, forwards to Future + } catch (e, s) { handleError(e, s); - }, - ); + } + }, handleError); return completer.future; } diff --git a/packages/flutter_tools/lib/src/debug_adapters/flutter_base_adapter.dart b/packages/flutter_tools/lib/src/debug_adapters/flutter_base_adapter.dart index bf4853c67be..bce7f9e53e1 100644 --- a/packages/flutter_tools/lib/src/debug_adapters/flutter_base_adapter.dart +++ b/packages/flutter_tools/lib/src/debug_adapters/flutter_base_adapter.dart @@ -28,10 +28,7 @@ abstract class FlutterBaseDebugAdapter super.enableAuthCodes, super.logger, super.onError, - }) : flutterSdkRoot = Cache.flutterRoot!, - // Always disable in the DAP layer as it's handled in the spawned - // 'flutter' process. - super(enableDds: false) { + }) : flutterSdkRoot = Cache.flutterRoot! { configureOrgDartlangSdkMappings(); } diff --git a/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart b/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart index 81ec2b0d00e..9659a3f7ad8 100644 --- a/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart @@ -1154,7 +1154,7 @@ void main() { // device.startApp() asynchronously calls throwToolExit, so we // catch it in a zone. unawaited( - runZoned?>( + runZonedGuarded?>( () { unawaited( device.startApp( @@ -1166,7 +1166,7 @@ void main() { ); return null; }, - onError: (Object error, StackTrace stack) { + (Object error, StackTrace stack) { expect(error.toString(), contains(jITCrashFailureInstructions('iOS 18.4'))); completer.complete(); }, diff --git a/packages/flutter_tools/test/general.shard/runner/runner_test.dart b/packages/flutter_tools/test/general.shard/runner/runner_test.dart index 5e3b1cb05c7..a49514f45e9 100644 --- a/packages/flutter_tools/test/general.shard/runner/runner_test.dart +++ b/packages/flutter_tools/test/general.shard/runner/runner_test.dart @@ -72,7 +72,7 @@ void main() { // runner.run() asynchronously calls the exit function set above, so we // catch it in a zone. unawaited( - runZoned?>( + runZonedGuarded?>( () { unawaited( runner.run( @@ -86,7 +86,7 @@ void main() { ); return null; }, - onError: (Object error, StackTrace stack) { + (Object error, StackTrace stack) { expect(firstExitCode, isNotNull); expect(firstExitCode, isNot(0)); expect(error.toString(), 'Exception: test exit'); @@ -133,7 +133,7 @@ void main() { // runner.run() asynchronously calls the exit function set above, so we // catch it in a zone. unawaited( - runZoned?>( + runZonedGuarded?>( () { unawaited( runner.run( @@ -149,7 +149,7 @@ void main() { ); return null; }, - onError: (Object error, StackTrace stack) { + (Object error, StackTrace stack) { expect(firstExitCode, isNotNull); expect(firstExitCode, isNot(0)); expect(error.toString(), 'Exception: test exit'); @@ -190,7 +190,7 @@ void main() { // runner.run() asynchronously calls the exit function set above, so we // catch it in a zone. unawaited( - runZoned?>( + runZonedGuarded?>( () { unawaited( runner.run( @@ -204,7 +204,7 @@ void main() { ); return null; }, - onError: (Object error, StackTrace stack) { + (Object error, StackTrace stack) { expect(firstExitCode, isNotNull); expect(firstExitCode, isNot(0)); expect(error.toString(), 'Exception: test exit'); @@ -297,7 +297,7 @@ void main() { // runner.run() asynchronously calls the exit function set above, so we // catch it in a zone. unawaited( - runZoned?>( + runZonedGuarded?>( () { unawaited( runner.run( @@ -311,7 +311,7 @@ void main() { ); return null; }, - onError: (Object error, StackTrace stack) { + (Object error, StackTrace stack) { expect(firstExitCode, isNotNull); expect(firstExitCode, isNot(0)); expect(error.toString(), 'Exception: test exit'); diff --git a/packages/flutter_tools/test/integration.shard/swift_package_manager_utils.dart b/packages/flutter_tools/test/integration.shard/swift_package_manager_utils.dart index d8ec358598e..365558f54ec 100644 --- a/packages/flutter_tools/test/integration.shard/swift_package_manager_utils.dart +++ b/packages/flutter_tools/test/integration.shard/swift_package_manager_utils.dart @@ -26,7 +26,6 @@ class SwiftPackageManagerUtils { 'Failed to enable Swift Package Manager: \n' 'stdout: \n${result.stdout}\n' 'stderr: \n${result.stderr}\n', - verbose: true, ); } @@ -45,7 +44,6 @@ class SwiftPackageManagerUtils { 'Failed to disable Swift Package Manager: \n' 'stdout: \n${result.stdout}\n' 'stderr: \n${result.stderr}\n', - verbose: true, ); }