Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@elliette
Copy link
Member

@elliette elliette commented Apr 7, 2025

Fixes #9102

Follow-up to #9100 which disabled the discarded_futures lint.

@elliette elliette requested review from a team, bkonyi and kenzieschmoll as code owners April 7, 2025 20:24
@elliette elliette changed the title Re-enabled discarded_futures lint Re-enable discarded_futures lint Apr 7, 2025
addAutoDisposeListener(_supportsToggleSelectWidgetMode, () async {
if (_supportsToggleSelectWidgetMode.value) {
serviceConnection.serviceManager.serviceExtensionManager
await serviceConnection.serviceManager.serviceExtensionManager
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment on lines 158 to 160
await _updateForServiceExtensionState(state.value, type);
addAutoDisposeListener(state, () async {
await _updateForServiceExtensionState(state.value, type);
Copy link
Member

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

@kenzieschmoll
Copy link
Member

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.

@elliette
Copy link
Member Author

elliette commented Apr 7, 2025

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 unawaited. Will respond when this is ready for re-review!

if (serviceConnection.serviceManager.connectedState.value.connected &&
controller.firstInspectorTreeLoadCompleted) {
controller.refreshInspector();
await controller.refreshInspector();
Copy link
Member Author

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

Copy link
Member

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

Copy link
Member Author

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);
Copy link
Member Author

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();
Copy link
Member Author

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();
Copy link
Member Author

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

@elliette
Copy link
Member Author

elliette commented Apr 8, 2025

Switched most futures from awaited to unawaited, the ones where I didn't I've left comments for why I think they should be awaited

if (serviceConnection.serviceManager.connectedState.value.connected &&
controller.firstInspectorTreeLoadCompleted) {
controller.refreshInspector();
await controller.refreshInspector();
Copy link
Member

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(
Copy link
Member

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.

Copy link
Member Author

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>

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

@kenzieschmoll kenzieschmoll left a 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 {
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, no!

@elliette elliette merged commit c2707cf into flutter:master Apr 10, 2025
41 checks passed
hrajwade96 pushed a commit to hrajwade96/devtools that referenced this pull request Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Latest Dart version catches many discarded_futures

2 participants