Skip to content

[CP-stable][ Widget Preview ] Don't crash when directory watcher restarts on Windows - #174055

Merged
auto-submit[bot] merged 3 commits into
flutter:flutter-3.35-candidate.0from
flutteractionsbot:cp-stable-02bf6d36c3ed450224080e39c25597805b241207
Aug 20, 2025
Merged

auto-submit[bot] merged 3 commits into
flutter:flutter-3.35-candidate.0from
flutteractionsbot:cp-stable-02bf6d36c3ed450224080e39c25597805b241207

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Aug 19, 2025 •

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?

#173895

Changelog Description:

Explain this cherry pick in one line that is accessible to most Flutter developers. See best practices for examples

When running on Windows, flutter widget-preview start eventually crashes due to an unhandled exception from the Windows file system watcher that should not be considered fatal.

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 production app (the app crashes on launch)

Given enough time, the file system watcher backing the WindowsDirectoryWatcher instance will add an error to the stream with the Directory watcher closed unexpectedly message. The WindowsDirectoryWatcher restarts the backing file system watcher, but if the event stream doesn't have an error handler registered, the tool crashes due to the unhandled exception.

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?

Run flutter widget-preview start on Windows for a prolonged period of time.

…dows (flutter#173987)

Fixes flutter#173895

This is a top-10 crasher for `3.35.{0,1}`.

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Aug 19, 2025
@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

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 Aug 19, 2025

@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 addresses a crash on Windows within the widget preview feature by handling an exception that occurs when the directory watcher restarts. The fix is implemented by adding an onError handler to the file watcher's event stream, specifically targeting the FileSystemException on Windows. The changes are well-structured, introducing a WatcherBuilder for better testability and updating relevant tests.

My review focuses on improving code maintainability by adding documentation. I've suggested adding doc comments for the new public typedef, fields, and constants to align with the Flutter style guide, which requires all public members to be documented.

Comment thread packages/flutter_tools/lib/src/widget_preview/preview_detector.dart
Comment thread packages/flutter_tools/lib/src/widget_preview/preview_detector.dart
Comment thread packages/flutter_tools/lib/src/widget_preview/preview_detector.dart
Comment thread packages/flutter_tools/lib/src/widget_preview/preview_detector.dart
@matanlurey

Copy link
Copy Markdown
Contributor

@bkonyi FYI this was created for you to fill out.

@bkonyi

bkonyi commented Aug 19, 2025

Copy link
Copy Markdown
Contributor

@bkonyi FYI this was created for you to fill out.

Thanks for the heads up. Done!

@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 20, 2025
@auto-submit
auto-submit Bot merged commit 03e97fb into flutter:flutter-3.35-candidate.0 Aug 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 26, 2025
@flutteractionsbot
flutteractionsbot deleted the cp-stable-02bf6d36c3ed450224080e39c25597805b241207 branch July 20, 2026 17:03
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 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