-
Notifications
You must be signed in to change notification settings - Fork 361
Re-enable discarded_futures lint
#9117
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
discarded_futures lintdiscarded_futures lint
| addAutoDisposeListener(_supportsToggleSelectWidgetMode, () async { | ||
| if (_supportsToggleSelectWidgetMode.value) { | ||
| serviceConnection.serviceManager.serviceExtensionManager | ||
| await serviceConnection.serviceManager.serviceExtensionManager |
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.
do we want to await this or was this intentionally unawaited?
| addAutoDisposeListener(_supportsToggleSelectWidgetMode, () async { | ||
| if (_supportsToggleSelectWidgetMode.value) { | ||
| serviceConnection.serviceManager.serviceExtensionManager | ||
| await serviceConnection.serviceManager.serviceExtensionManager |
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.
same
| await _updateForServiceExtensionState(state.value, type); | ||
| addAutoDisposeListener(state, () async { | ||
| await _updateForServiceExtensionState(state.value, type); |
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.
same question regarding whether these were intentionally unawaited
|
Looking at this PR further, I worry we are changing the functionality of the code to enable this lint. Some of this code looks like it should be intentionally unawaited so that it does not block the UI thread. |
Hmm I will go through these changes again and update the ones which like they should be |
| if (serviceConnection.serviceManager.connectedState.value.connected && | ||
| controller.firstInspectorTreeLoadCompleted) { | ||
| controller.refreshInspector(); | ||
| await controller.refreshInspector(); |
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 believe it is better to await the tree refresh here to avoid race conditions
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.
Is the closure awaited when the listener is called in the auto dispose logic? If not, this await won't matter and we should add a comment or explicitly mark unawaited
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.
Ah good point, it's not. Switched to unawaited
| Future<Success> streamCancel(String streamId) { | ||
| _activeStreams.remove(streamId); | ||
| Future<Success> streamCancel(String streamId) async { | ||
| await _activeStreams.remove(streamId); |
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 looks like it should have always been awaited
| client.sink!.done.whenComplete(() async { | ||
| finishedCompleter.complete(); | ||
| service.dispose(); | ||
| await service.dispose(); |
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 think we should wait for dispose after the connection is closed here
| (_) async { | ||
| finishedCompleter.complete(); | ||
| service.dispose(); | ||
| await service.dispose(); |
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.
Same comment as above here
|
Switched most futures from |
| if (serviceConnection.serviceManager.connectedState.value.connected && | ||
| controller.firstInspectorTreeLoadCompleted) { | ||
| controller.refreshInspector(); | ||
| await controller.refreshInspector(); |
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.
Is the closure awaited when the listener is called in the auto dispose logic? If not, this await won't matter and we should add a comment or explicitly mark unawaited
| _UiPreferences.vmDeveloperMode.storageKey, | ||
| '${vmDeveloperModeEnabled.value}', | ||
| safeUnawaited( | ||
| storage.setValue( |
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.
do we ever await storage.setValue? If not, we could change the return type of setValue to void and then add the safeUnawatied wrapper inside that method.
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.
Good point, setValue now returns void instead of Future<void>
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 looks like we were awaiting storage.setValue in some places though. My comment was only if we weren't awaiting this method call anywhere but it looks like we were. I don't know if we want to change the behavior of places where we were awaiting.
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.
Ah got it! Reverted those changes
kenzieschmoll
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 with one question
| serviceConnection.serviceManager.serviceExtensionManager | ||
| .waitForServiceExtensionAvailable(extension.extension) | ||
| .then((isServiceAvailable) { | ||
| .then((isServiceAvailable) 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.
is this async still needed?
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.
good catch, no!
Fixes #9102
Follow-up to #9100 which disabled the
discarded_futureslint.