-
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
method-side opt-out for unawaited_futures #2513
Comments
Just to be clear, in other cases, you do want to wait for the Future, and access a contained value? |
Yes. For example, if a route pushed via |
There's some conceptual common ground with the open request for |
Is there a way that we can statically tell whether it's reasonable to drop the |
It's ok to ignore a future when that future will never complete with an exception. It would be good for the lint to make that clear (e.g. |
Annotation implementation in the SDK discussion going on here: dart-lang/sdk#46218. |
This is a duplicate of what #2513 eventually became, as of #419 (comment). #419 (comment) is a good summary. |
Do you have an example diff or diagnostics list from when this was explored in
I'm surprised that the noise of Is it intended that errors from these futures should be surfaced only by the zone error handler? |
Turning on the lint on flutter/flutter reports almost 800 issues: https://gist.github.com/goderbauer/2e74e4299b82a7106dc47c012ca9e153. I haven't checked all of these, but the ones I spot-checked where reported on
See Hixie's earlier comment in this thread. These futures are designed to never complete with an exception. |
In that case is there any concern with using |
It's noisy, verbose, and somewhat annoying. If we already know that these can be safely ignored, why do our developers have to spent mental energy on the question of whether ignoring these is fine or not? Also, if developers make the wrong choice and accidentally await these (the lint is pushing them more in that direction then towards ignoring them) they'll have to spent more time debugging why their test is hanging. |
The other problem with |
Flutter has some API methods (like Navigator.push, AnimationController.forward, AnimationController.reverse) that return a Future, but in a lot of cases it is perfectly normal to just drop that Future on the floor. The
unawaited_futures
lint creates a lot of noise there, especially in tests.It would be nice if there's an API-side opt-out for that lint where we can annotate the methods mentioned above with
@unawaitedOk
(or similar) and the lint would ignore it if a Future returned by those annotated methods is unawaited./cc @pq @Hixie @mit-mit @munificent @devoncarew
The text was updated successfully, but these errors were encountered: