Report async callback errors that currently go unreported.#34081
Report async callback errors that currently go unreported.#34081aam merged 4 commits intoflutter:masterfrom
Conversation
| } | ||
| return 0; | ||
| String getVersion() => flutterVersion ?? FlutterVersion.instance.getVersionString(redactUnknownBranches: true); | ||
| return runZoned<Future<int>>(() async { |
There was a problem hiding this comment.
Nit: return await runZoned...
| error, stackTrace, verbose, args, reportCrashes, getVersion); | ||
| } | ||
| }, onError: (Object error, StackTrace stackTrace) async { | ||
| await _handleToolError( |
There was a problem hiding this comment.
This will make the outer call to runZoned() return null, correct? Should we wrap that null in a non-zero synthetic exit code?
There was a problem hiding this comment.
I don't think so: _handleToolError invoked from this onError handler will terminate the flutter with exit code derived from what kind error the error is(ToolExit, ProcessExit, something unexpected).
If we end up in onError, then runZoned() returned a future that never completes because of unhandled exception.
There was a problem hiding this comment.
It'll call exit(), but that can be overridden for tests. I'm just curious what the return value of run() will be in that case.
There was a problem hiding this comment.
we only end up in onError through async callback/flow, and that flow won't affect runZoned return-value. We might have used Completer or something similar to communicate between this callback and method that runZoned is executing, but that seems unnecessary - we can simply exit the tool.
| } | ||
| return 0; | ||
| String getVersion() => flutterVersion ?? FlutterVersion.instance.getVersionString(redactUnknownBranches: true); | ||
| return await runZoned<Future<int>>(() async { |
There was a problem hiding this comment.
We should replicate the case this is guarding against in a test.
Added. |
One example of unreported errors is #33938 where adb is invoked when broadcast stream is created in a _start callback
flutter/packages/flutter_tools/lib/src/android/android_device.dart
Line 668 in 041755f