Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

flutteractionsbot
Copy link

@flutteractionsbot flutteractionsbot commented Aug 19, 2025

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
Author

@bkonyi please fill out the PR description above, afterwards the release team will review this request.

@flutter-dashboard
Copy link

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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 correctly handling a FileSystemException from the directory watcher. The implementation is solid, introducing dependency injection for Platform and Watcher to enhance testability. My feedback is focused on improving documentation by adding comments to new public members, ensuring adherence to the Flutter style guide.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 19, 2025
@matanlurey
Copy link
Contributor

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

@bkonyi
Copy link
Contributor

bkonyi commented Aug 19, 2025

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

Thanks. 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 025ed8a into flutter:flutter-3.36-candidate.0 Aug 20, 2025
144 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 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