-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[various] Fixes unawaited_futures
violations
#4067
Conversation
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 for go_router and go_router_builder
# TODO(stuartmorgan): Remove this file and fix all the unawaited_futures | ||
# violations. See https://github.com/flutter/flutter/issues/127323 | ||
|
||
include: ../../../analysis_options.yaml |
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.
Unrelated to this pr. I wish we used absolute paths instead of relative paths when the absolute path has more meaning.
I know that effective dart says to prefer relative paths but in this case it matters more that we are using the root analysis_options.yaml than the one 3 folders up.
https://dart.dev/effective-dart/usage#prefer-relative-import-paths
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 agree that would be better in this case, but I don't think it's actually possible; there's no package at the root.
I guess we could make a local package with the shared options, and then depend on that in every single pubspec.yaml so we could use a package:
URL, but that would be pretty ugly. And the local package reference in the pubspec would have to be... a relative path.
linter: | ||
rules: | ||
# Matches flutter/flutter, which disables this rule due to false positives. | ||
unawaited_futures: false |
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.
Mild preference for ignore for file in the test than opting out the directory.
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.
pigeon and shared_prefs are fine, assuming ci doesn't hang on pigeon tests
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.
Not sure why I left some of the calls sneakily unawaited, but CI will tell. 🚀
Looks like this was aspirational. Not too many failures though; I'll take a look tomorrow. |
@@ -27,7 +27,7 @@ void main() { | |||
final dom.DomHtmlElement target = dom.document.createElement('div'); | |||
|
|||
test('Injects script into desired target', () async { | |||
loadWebSdk(target: target); | |||
await loadWebSdk(target: target); |
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 change was incorrect; the test never simulates running the callback, causing the test to hang; I'll make it unawaited
with a comment.
return (_initialization ??= _doInitialization()).catchError((dynamic _) { | ||
// Invalidate initialization if it errors out. | ||
_initialization = null; | ||
}); |
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.
Apparently the fact that the error wasn't being caught by the returned future was (or at least has become) intentional behavior, since there was a unit test that this change broke. I doubt very much that having _initialization
not be guaranteed to be null when the future completes is intentional though, so I changed it to return the catchError
wrapper, but made the wrapper rethrow after nulling _initialization
.
flutter/packages@fba97fa...995bfc5 2023-05-24 [email protected] Roll Flutter from f86c529 to 216605b (18 revisions) (flutter/packages#4071) 2023-05-24 [email protected] [various] Fixes `unawaited_futures` violations (flutter/packages#4067) 2023-05-24 [email protected] [quick_actions] Fix iOS home screen quick actions documentation hyperlink (flutter/packages#4059) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…4171) In #4067 I changed several implicitly unawaited futures to `await`, not noticing that doing so would change the timing on updating fields that were used to compute diffs for future updates. Since the update flow is unawaited at higher levels, this meant that multiple calls to update map objects in rapid succession would compute incorrect diffs due to using the wrong base objects. This fixes that by restoring the old flow using `unawaited`. Adds new tests that introduce synthetic awaits into the fake platform interface object and perform multiple updates in a row that should have different base object sets, which fail without the fix. In order to simplify adding that behavior to the fake, and to pay down technical debt in the unit tests, I replaced the old test fake that is based on method channel interception (which predates the federation of the plugin and is implicitly relying on the method channel implementation from a different package never changing) with a fake platform interface implementation (substantially simplifying the fake). Fixes flutter/flutter#128042
Some packages require package upgrade rather than simple modification (ex: google_maps_flutter) Therefore, the rules below are temporarily ignored. Any necessary modifications can be applied in a later PR. flutter/packages#4060 - unnecessary_null_comparison flutter/packages#4067 - unawaited_futures flutter/packages#5717 - dangling_library_doc_comments - no_literal_bool_comparisons - unnecessary_library_directive - use_colored_box - use_enums - use_string_in_part_of_directives
This option had been disabled to match flutter/flutter, but the reason it was disabled there was "too many false positives", mostly around animation. That doesn't apply to most packages here, and we've had a number of production bugs—especially in plugins, that use async heavily in ways that are intended to be client-awaitable—that this would have caught.
This PR:
animations
andgo_router
, both of which looked like mostly or entirely false positives.camera_android_camerax
, most ofwebview_flutter
).In many cases this PR is behavior-changing, replacing implicitly unawaited futures that did not seem obviously intentional with
await
ed futures, so non-test code in particular should be reviewed carefully to make sure the changes are correct. All of the changes are manual, notfix
-generated.Part of flutter/flutter#127323
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).