-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Report async callback errors that currently go unreported. #34081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tvolkert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test?
| } | ||
| return 0; | ||
| String getVersion() => flutterVersion ?? FlutterVersion.instance.getVersionString(redactUnknownBranches: true); | ||
| return runZoned<Future<int>>(() async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: return await runZoned...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| error, stackTrace, verbose, args, reportCrashes, getVersion); | ||
| } | ||
| }, onError: (Object error, StackTrace stackTrace) async { | ||
| await _handleToolError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should replicate the case this is guarding against in a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Added. |
tvolkert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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