Skip to content

[flutter_tools] FormatException in chunked JSON stream parser when socket/process emits plain-text error #191898

Closed

Description

@bkonyi

Crash Report Details

  • Signature: FormatException at _ChunkedJsonParser.fail at dart:convert-patch/convert_patch.dart-31c7f14c
  • Exception: FormatException
  • Volume: 245 crashes (11.7% share of Top 10 in Flutter 3.47.1)
  • Error Message:
    FormatException: Unexpected character (at character 1)
    Loading dynamic library failed: dlopen(/opt/homebrew/share/flutter/bin/cach...
    ^
    
    or
    FormatException: Unexpected character (at character 1)
    Error: launching development server failed : Unable to find snapshot for th...
    ^
    

Stack Trace

_ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1466)
_ChunkedJsonParser.parseNumber / parse (dart:convert-patch/convert_patch.dart:934)
_JsonStringDecoderSink.addSlice (dart:convert-patch/convert_patch.dart:1554)
_ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:70)
_SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:798)
_Socket._onData (dart:io-patch/socket_patch.dart:2906)

Context & Root Cause Analysis

During test execution or process communication (such as in flutter_platform.dart and flutter_web_platform.dart), streams and WebSocket channels expect string-encoded JSON payloads from the remote runner or test process (e.g. _pipeHarnessToRemote or BrowserManager).

When a test runner process or socket emits unformatted, non-JSON plain text error output directly over the channel (for instance, native dynamic library loading failure messages, snapshot lookup errors, or subprocess failure messages), the incoming data is passed directly into json.decode or jsonDocument (_ChunkedJsonParser). Because the payload begins with characters like L or E instead of valid JSON tokens, _ChunkedJsonParser throws an unhandled FormatException at character 1.

The unhandled FormatException crashes the Flutter CLI tool instead of being safely intercepted, logged as a warning/trace, and handled gracefully.

Proposed Fix

Safely intercept non-JSON string payloads in stream communication handlers (in flutter_platform.dart and flutter_web_platform.dart), log unexpected output to trace and warning logs, and handle test/device runner termination cleanly without crashing the tool process with an unhandled exception.

Activity

  1. added
    c: crashStack traces logged to the console
    team-toolOwned by Flutter Tool team
    on Aug 27, 2026
  2. github-actions commented on Sep 18, 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.

  3. locked as resolved and limited conversation to collaborators on Sep 18, 2026
  4. added
    P1High-priority issues at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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.47t: top-crasherteam-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