Skip to content

[flutter_tools] Unhandled String exception when VM service connection closes before HTTP header completion (HttpException) #191178

Closed

Description

@bkonyi

Summary

In Flutter 3.47.0 telemetry, an unhandled String exception during VM Service connection establishment emerged as a top crash signature.

During application launch or debugger attach, if the remote socket resets before HTTP headers are received, dart:io throws HttpException. The connection error was formatted as a raw String and passed to Completer.completeError(), which bypassed on Exception catch blocks in callers and crashed the tool.

Telemetry Profile

  • Release: Flutter 3.47.0 (Top 10 crasher)
  • Signature: String-3df63b7a

Error Output

String: failed to connect to http://127.0.0.1:63745/TjwUKCgX5S8=/ HttpException: Connection closed before full header was received, uri = http://127.0.0.1:63745/TjwUKCgX5S8=/ws

Root Cause

  1. In packages/flutter_tools/lib/src/vmservice.dart, _defaultOpenChannel only caught WebSocketException and SocketException for retries, omitting io.HttpException. Transient socket resets during handshake failed immediately without retries.
  2. In packages/flutter_tools/lib/src/resident_runner.dart (FlutterDevice.connect), connection failures were passed to completer.completeError('failed to connect to $vmServiceUri $e', st) as a raw String.
  3. Callers (ColdRunner, HotRunner) use on Exception catch (...), which does not catch String, allowing the error to propagate unhandled to the top level.

Proposed Fix

  • Add on io.HttpException to _defaultOpenChannel retry loop in vmservice.dart.
  • Complete error completers in FlutterDevice.connect with typed Exception objects instead of String.
  • Track isConnecting and error state on stream closure in ResidentRunner.connect.

Activity

  1. added
    c: crashStack traces logged to the console
    toolAffects the "flutter" command-line tool. See also t: labels.
    team-toolOwned by Flutter Tool team
    P1High-priority issues at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    on Aug 16, 2026
  2. self-assigned this
    on Aug 16, 2026
  3. github-actions commented on Sep 2, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: crashStack traces logged to the consolefound in release: 3.47Found to occur in 3.47team-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions