-
Notifications
You must be signed in to change notification settings - Fork 170
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
New lint suggestion: uncaught_async_error_in_try_catch
#4833
Comments
Good catch, @gmpassos! The behavior which is described here is a bug, reported in dart-lang/sdk#44395. So the async error should have been caught. However, a fix for the bug was created already a couple of years ago, and then it was never landed because it gave rise to subtle breakages. In short, we kept the bug because it seemed more disruptive to fix it. The issue is (finally) being handled in the coming months, as described in this comment. It may or may not be justified to create a lint as requested here, given that the issue is gone as soon as we have an implementation of dart-lang/language#870, and the code has been migrated to use that. On the other hand, it certainly won't hurt to have a lint like this. It would nudge developers in the direction of pre-migrating their code to the form that it needs to have anyway when dart-lang/language#870 has been implemented. |
If, in the future, Dart doesn't allow returning a Future without await inside an async block, it could potentially break a lot of code. IMHO I consider it a bug only if it's inside a "try" block, as without it (try block), the behavior remains the same with or without await. It might be challenging to implement this language change, and it could take a while to release it. A lint could help resolve the issue for now, in a simple and compatible way. Also, consider allowing the return of Future (or anything) without await for a method returning FutureOr to avoid disrupting optimizations, since a method that returns FutureOr usually is attempting to optimize things. See https://pub.dev/packages/async_extension |
@gmpassos, you might want to add this comment to dart-lang/language#870, it seems to be more relevant there. |
THX. I have just commented there. |
I suggest the lint
uncaught_async_error_in_try_catch
(or a better name), for the example bellow:Without a lint the issue above is not simple to detect and debug and can generate many bugs.
The text was updated successfully, but these errors were encountered: