Re-enable discarded_futures lint#9117
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.
do we want to await this or was this intentionally unawaited?
| addAutoDisposeListener(_supportsToggleSelectWidgetMode, () async { | ||
| if (_supportsToggleSelectWidgetMode.value) { | ||
| serviceConnection.serviceManager.serviceExtensionManager | ||
| await serviceConnection.serviceManager.serviceExtensionManager |
| await _updateForServiceExtensionState(state.value, type); | ||
| addAutoDisposeListener(state, () async { | ||
| await _updateForServiceExtensionState(state.value, type); |
There was a problem hiding this comment.
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.
I believe it is better to await the tree refresh here to avoid race conditions
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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.
Good point, setValue now returns void instead of Future<void>
There was a problem hiding this comment.
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.
Ah got it! Reverted those changes
| serviceConnection.serviceManager.serviceExtensionManager | ||
| .waitForServiceExtensionAvailable(extension.extension) | ||
| .then((isServiceAvailable) { | ||
| .then((isServiceAvailable) async { |
There was a problem hiding this comment.
is this async still needed?
Fixes #9102
Follow-up to #9100 which disabled the
discarded_futureslint.