Skip to content

[stable] [flutter_tools] Handle HttpException during VM service connection - #191607

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
bkonyi:cherry-pick-191182-to-stable
Aug 24, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.47-candidate.0from
bkonyi:cherry-pick-191182-to-stable

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Issue Link:

#191178

Impact Description:

During application launch or debugger attach (flutter run / flutter attach), transient socket resets before HTTP headers complete cause dart:io to throw HttpException. The connection error was formatted as a raw String and passed to Completer.completeError(), which bypassed on Exception catch blocks in ColdRunner and HotRunner and resulted in unhandled crashes. This is a top-10 crash signature in Flutter 3.47.0 telemetry.

Changelog Description:

[flutter/191178] Handle HttpException during VM service connection retries and ensure typed exceptions are passed to error completers.

Workaround:

Rerun flutter run or flutter attach to re-attempt connection.

Risk:

  • Low
  • Medium
  • High

Test Coverage:

  • Yes
  • No

Validation Steps:

  1. Run unit tests in packages/flutter_tools/test/general.shard/vmservice_test.dart and packages/flutter_tools/test/general.shard/resident_runner_test.dart.
  2. Launch a Flutter app and verify that transient VM service connection resets are retried and caught cleanly without crashing the CLI with an unhandled String exception.

…utter#191182)

This PR handles `io.HttpException` thrown during the VM service
connection process in `flutter_tools`.

### Problem
When connecting to the VM service, if the server closes the HTTP
connection prematurely (e.g., "Connection closed before full header was
received"), `io.WebSocket.connect` throws an `io.HttpException`. This
exception was not caught in `_defaultOpenChannel` in `vmservice.dart`,
causing the connection loop to terminate abruptly with an unhandled
exception and crashing the tool.

### Fix
- Added `io.HttpException` to the caught exceptions in
`_defaultOpenChannel` (`vmservice.dart`), ensuring connection attempts
retry with exponential backoff rather than crashing.
- Added unit test in `vmservice_test.dart` verifying retry messages and
logging behavior when `io.HttpException` is encountered during
connection.

Fixes flutter#191178
@bkonyi bkonyi added the cp: review Cherry-picks in the review queue label Aug 24, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Aug 24, 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.

@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 updates the VM service connection logic in vmservice.dart to catch io.IOException instead of specifically catching io.WebSocketException and io.SocketException. This allows handling other types of IO exceptions, such as io.HttpException. Additionally, a corresponding test has been added in vmservice_test.dart to verify that connection failures caused by io.HttpException are properly logged and retried. There are no review comments, and I have no feedback to provide.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 24, 2026
@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 24, 2026
@auto-submit
auto-submit Bot merged commit b3bc058 into flutter:flutter-3.47-candidate.0 Aug 24, 2026
10 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.

2 participants