-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[ Tool ] Don't try to reattach when attach target disappears #179193
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
Before this change, there was logic in `flutter attach` that would try and listen for a new application to attach to in the scenario the current target application disappeared. This behavior isn't documented, and has resulted in a `StateError` being thrown due to the VM service URIs stream being listened to multiple times. This change removes this behavior, which also prevents the `StateError` from being thrown. Fixes #156692
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.
Code Review
This pull request refactors the flutter attach command to remove the undocumented and buggy re-attachment logic. The changes are well-structured, extracting logic into new private methods which improves readability and maintainability. The core fix of removing the re-attachment loop correctly resolves the reported StateError. Additionally, the return types for run and attach methods in ResidentRunner have been updated for better null safety, and a regression test has been added to ensure the fix is permanent. The changes look solid.
jyameo
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!
| ); | ||
| } | ||
|
|
||
| Future<void> _validateArguments() 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.
The _validateArguments method wasn't doing anything before it seems, so removing it makes sense. Just confirming that the intent here is not to include any argument validation logic here.
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.
Correct!
|
Failed to create CP due to merge conflicts. |
1 similar comment
|
Failed to create CP due to merge conflicts. |
flutter/flutter@022b155...2b5fa94 2025-11-29 [email protected] Roll Fuchsia Linux SDK from 3mkBM9XuntkUl3G9l... to sY2ExxZc0A8bgMF11... (flutter/flutter#179233) 2025-11-29 [email protected] Roll Dart SDK from 09b91afe9f4d to 56cc05dd11a8 (1 revision) (flutter/flutter#179231) 2025-11-28 [email protected] [ Tool ] Don't try to reattach when attach target disappears (flutter/flutter#179193) 2025-11-28 [email protected] Roll Dart SDK from 4bd803e19d22 to 09b91afe9f4d (1 revision) (flutter/flutter#179222) 2025-11-28 [email protected] Fix GitHub Actions not pinned by hash (flutter/flutter#178917) 2025-11-28 [email protected] Update workflow permissions in easy-cp.yml (flutter/flutter#178919) 2025-11-28 [email protected] Roll Packages from b505d41 to c8be05d (1 revision) (flutter/flutter#179218) 2025-11-28 [email protected] Roll Dart SDK from 394606994711 to 4bd803e19d22 (1 revision) (flutter/flutter#179215) 2025-11-28 [email protected] Roll Dart SDK from 74247cdd0f18 to 394606994711 (1 revision) (flutter/flutter#179205) 2025-11-28 [email protected] Roll Fuchsia Linux SDK from _e9MNK4nfBOrERVP_... to 3mkBM9XuntkUl3G9l... (flutter/flutter#179203) 2025-11-28 [email protected] Roll Dart SDK from 1e6edf8a8dab to 74247cdd0f18 (2 revisions) (flutter/flutter#179201) 2025-11-27 [email protected] [ Widget Preview ] Handle changes to unexpected pubspec.yaml files gracefully (flutter/flutter#179157) 2025-11-27 [email protected] Roll Dart SDK from 1d8dc04bd1d7 to 1e6edf8a8dab (9 revisions) (flutter/flutter#179190) 2025-11-27 [email protected] Roll Packages from 5d8d954 to b505d41 (4 revisions) (flutter/flutter#179188) 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 Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Before this change, there was logic in `flutter attach` that would try and listen for a new application to attach to in the scenario the current target application disappeared. This behavior isn't documented, and has resulted in a `StateError` being thrown due to the VM service URIs stream being listened to multiple times. This change removes this behavior, which also prevents the `StateError` from being thrown. Fixes #156692, which is a top-10 crasher for the tool.
…#179193) Before this change, there was logic in `flutter attach` that would try and listen for a new application to attach to in the scenario the current target application disappeared. This behavior isn't documented, and has resulted in a `StateError` being thrown due to the VM service URIs stream being listened to multiple times. This change removes this behavior, which also prevents the `StateError` from being thrown. Fixes flutter#156692, which is a top-10 crasher for the tool.
…rs (#179193) (#179291) This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: What is the link to the issue this cherry-pick is addressing? #156692 ### Changelog Description: Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples `flutter attach` can crash if the target application disconnects unexpectedly. ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch) The `flutter attach` process could crash when trying to attach to a new target after the initial target disappeared unexpectedly. This could result in an error popup in IDEs or an obvious crash on the CLI. This is a top-10 crasher for the tool. ### Workaround: Is there a workaround for this issue? N/A ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: What are the steps to validate that this fix works? 1) Run `flutter run` to deploy to an Android or iOS device. 2) Run `flutter attach` to connect to the running application. 3) Kill the running application by pressing `q` in the `flutter run` terminal. 4) The `flutter attach` process should simply exit with no crash.
…#179193) Before this change, there was logic in `flutter attach` that would try and listen for a new application to attach to in the scenario the current target application disappeared. This behavior isn't documented, and has resulted in a `StateError` being thrown due to the VM service URIs stream being listened to multiple times. This change removes this behavior, which also prevents the `StateError` from being thrown. Fixes flutter#156692, which is a top-10 crasher for the tool.
Before this change, there was logic in
flutter attachthat would try and listen for a new application to attach to in the scenario the current target application disappeared. This behavior isn't documented, and has resulted in aStateErrorbeing thrown due to the VM service URIs stream being listened to multiple times.This change removes this behavior, which also prevents the
StateErrorfrom being thrown.Fixes #156692, which is a top-10 crasher for the tool.