Skip to content

[CP-stable][flutter_tools] Safely handle non-JSON messages in test stream parsers - #192419

Merged
auto-submit[bot] merged 2 commits into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-ed37ea92684ce88acf90e7c9af630c2bcf57acd7
Sep 10, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:flutter-3.47-candidate.0from
flutteractionsbot:cp-stable-ed37ea92684ce88acf90e7c9af630c2bcf57acd7

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Sep 8, 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:

#191898

Impact Description:

Top crash in Flutter 3.47.1 accounting for 245 crashes (11.7% share of top crashes). When a test runner process or browser socket dumps unformatted non-JSON error output (such as dynamic library loading errors or missing snapshot warnings) directly onto the test communication stream or WebSocket, _ChunkedJsonParser throws an unhandled FormatException: Unexpected character (at character 1), terminating the flutter test CLI process.

Changelog Description:

[flutter/191898] When remote test processes emit plain-text error output on all platforms, prevent flutter_tools from crashing with an unhandled FormatException.

Workaround:

None. Any test execution where a child runner or socket prints plain text instead of JSON fatal crashes the test runner CLI.

Risk:

  • Low
  • Medium
  • High

Test Coverage:

  • Yes
  • No

Validation Steps:

Run flutter test test/general.shard/flutter_platform_test.dart and flutter test test/commands.shard/hermetic/flutter_web_platform_test.dart.
Specifically, pipeHarnessToRemote safely ignores non-JSON string and logs warning validates that plain text received over the stream logs a warning/trace without crashing the process, and subsequent valid JSON packets are processed normally.

flutter#192089)

When communicating with remote test runners or browsers over test
streams or WebSockets, unhandled non-JSON strings (such as dynamic
library loading errors or missing snapshot warnings) caused
`_ChunkedJsonParser` to throw an unhandled `FormatException` at
character 1, crashing the tool.

This changes `pipeHarnessToRemote` in `flutter_platform.dart` and
`BrowserManager` in `flutter_web_platform.dart` to intercept non-JSON
payloads, log warnings and traces, and ignore invalid frames rather than
crashing the tool process.

Fixes flutter#191898

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [ ] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Sep 8, 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 Sep 8, 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 Sep 8, 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 updates the test platform and web platform implementations to handle FormatException during JSON decoding of streams from the test runner and browser WebSocket, logging a warning and trace message instead of failing. It also exposes pipeHarnessToRemote for testing and adds a unit test to verify this behavior. I have no feedback to provide.

@walley892

Copy link
Copy Markdown
Contributor

@bkonyi. Spoke too soon - could you add a secondary reviewer here as well?

@bkonyi
bkonyi requested a review from dcharkes September 9, 2026 19:04
dcharkes
dcharkes previously approved these changes Sep 9, 2026
walley892
walley892 previously approved these changes Sep 9, 2026
@walley892 walley892 added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 9, 2026
@auto-submit

auto-submit Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 9, 2026
@walley892

Copy link
Copy Markdown
Contributor

Hi @bkonyi, I think there may be a dependency that also needs to be cherry picked.

…logging

When cherry-picking flutter#192089 to the stable release candidate branch
`flutter-3.47-candidate.0`, `BrowserManager` in `flutter_web_platform.dart`
referenced `_logger` without `_logger` being defined on `BrowserManager`
(which was added on `master` in a later Chrome roll PR).

This passes `_logger` from `FlutterWebPlatform` through `BrowserManager.start`
and stores it on `BrowserManager` so that unexpected non-JSON messages can be
logged as intended.
@bkonyi
bkonyi dismissed stale reviews from walley892 and dcharkes via bc56bc9 September 10, 2026 16:31
@bkonyi

bkonyi commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Should be fixed now!

@walley892 walley892 added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 10, 2026
@auto-submit
auto-submit Bot merged commit 9584c67 into flutter:flutter-3.47-candidate.0 Sep 10, 2026
8 checks passed
@flutteractionsbot
flutteractionsbot deleted the cp-stable-ed37ea92684ce88acf90e7c9af630c2bcf57acd7 branch September 10, 2026 22:25
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.

4 participants