Skip to content

[CP-stable][Tool Robustness] Gracefully handle asynchronous subprocess crashes and connection timeouts#187118

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.44-candidate.0from
flutteractionsbot:cp-stable-12ea3264eca17e583664778d794dca3a0846a406
May 28, 2026
Merged

[CP-stable][Tool Robustness] Gracefully handle asynchronous subprocess crashes and connection timeouts#187118
auto-submit[bot] merged 1 commit into
flutter:flutter-3.44-candidate.0from
flutteractionsbot:cp-stable-12ea3264eca17e583664778d794dca3a0846a406

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented May 26, 2026

Copy link
Copy Markdown
Contributor

This pull request is created by automatic cherry pick workflow
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?

#186962
#186963

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 of production apps (the app crashes on launch).
This information is for domain experts and release engineers to understand the consequences of saying yes or no to the cherry pick.

The Flutter Tool crashes instead of exiting gracefully. These two issues are top-10 crashers for the tool on 3.44.0.

Changelog Description:

Explain this cherry pick:

  • In one line that is accessible to most Flutter developers.
  • That describes the state prior to the fix.
  • That includes which platforms are impacted.
    See best practices for examples.

[flutter/186962] When the analysis server exits unexpectedly, the flutter tool can crash instead of outputting a descriptive error message.
[flutter/186963] When failing to connect to a Chrome instance on Windows, the flutter tool can crash instead of outputting a descriptive error message.

Workaround:

Is there a workaround for this issue?

No.

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

What are the steps to validate that this fix works?

These crashes are flaky and hard to reproduce. Will need to monitor tool crash reports for the next stable release to verify.

…nd connection timeouts (flutter#186964)

Avoid crashing the flutter tool when the analysis server subprocess
exits prematurely (e.g. with 255) or when the web debug connection times
out.

For the analysis server, we introduce a private
_AnalysisServerExitException and map it to a clean ToolExit when
awaiting the analysis.

For the web runner, we attach a .catchError handler to the connectDebug
future to handle connection timeouts, printing a clear error and exiting
via ToolExit instead of raising an unhandled async error.

Fixes flutter#186962
Fixes flutter#186963
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label May 26, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor Author

@bkonyi please fill out the PR description above, afterwards the release team will review this request.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 26, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 26, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 improves error handling by introducing structured exceptions and timeouts. It defines a custom _AnalysisServerExitException to propagate exit codes during single-run analysis, and handles TimeoutException in the web runner to throw user-friendly ToolExit errors. Corresponding unit tests have been added to verify these behaviors. The reviewer suggests implementing toString() on the custom _AnalysisServerExitException class to ensure it provides a meaningful string representation if printed or logged.

Comment on lines +182 to +186
class _AnalysisServerExitException implements Exception {
_AnalysisServerExitException(this.message, this.exitCode);
final String message;
final int? exitCode;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Implementing toString() on custom exception classes is a good practice to ensure that if the exception is ever printed, logged, or string-interpolated, it provides a meaningful message instead of the default Instance of '_AnalysisServerExitException'.

Suggested change
class _AnalysisServerExitException implements Exception {
_AnalysisServerExitException(this.message, this.exitCode);
final String message;
final int? exitCode;
}
class _AnalysisServerExitException implements Exception {
_AnalysisServerExitException(this.message, this.exitCode);
final String message;
final int? exitCode;
@override
String toString() => message;
}

@reidbaker reidbaker added the autosubmit Merge PR when tree becomes green via auto submit App label May 27, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 27, 2026
@auto-submit

auto-submit Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/187118, because - The status or check suite Linux framework_tests_widgets has failed. Please fix the issues identified (or deflake) before re-applying this label.

@reidbaker reidbaker added the autosubmit Merge PR when tree becomes green via auto submit App label May 28, 2026
@auto-submit auto-submit Bot merged commit c8b7441 into flutter:flutter-3.44-candidate.0 May 28, 2026
155 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD cp: review Cherry-picks in the review queue tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants