Skip to content

[ Widget Previews ] Watcher stream subscription should handle Directory watcher closed unexpectedly exception on Windows #173895

Closed

Description

@RoarGronmo

Command

flutter widget-preview start

Steps to Reproduce

  1. ...
  2. ...
  3. ...

Logs

FileSystemException: Directory watcher closed unexpectedly, null

#0      _FileSystemWatcher._listenOnSocket.<anonymous closure> (dart:io-patch/file_patch.dart:408:11)
#1      _ExpandStream._handleData (dart:async/stream_pipe.dart:266:30)
#2      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:184:13)
#3      _rootRunUnary (dart:async/zone.dart:1546:13)
#4      _CustomZone.runUnary (dart:async/zone.dart:1429:19)
#5      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1329:7)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:381:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:312:7)
#8      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:798:19)
#9      _StreamController._add (dart:async/stream_controller.dart:663:7)
#10     _StreamController.add (dart:async/stream_controller.dart:618:5)
#11     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:2338:33)
#12     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1648:18)
#13     _microtaskLoop (dart:async/schedule_microtask.dart:40:35)
#14     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#15     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:127:13)
#16     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:194:5)
�[32m[✓]�[39m Flutter (Channel beta, 3.36.0-0.1.pre, on Microsoft Windows [Version 10.0.26100.4946], locale nb-NO) [543ms]
    �[32m•�[39m Flutter version 3.36.0-0.1.pre on channel beta at c:\Flutter\flutter
    �[32m•�[39m Upstream repository https://github.com/flutter/flutter.git
    �[32m•�[39m Framework revision c84cdd0d0b (2 days ago), 2025-08-13 17:21:27 -0700
    �[32m•�[39m Engine revision 877970cbc9
    �[32m•�[39m Dart version 3.10.0 (build 3.10.0-75.1.beta)
    �[32m•�[39m DevTools version 2.49.0
    �[32m•�[39m Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-lldb-debugging

�[32m[✓]�[39m Windows Version (11 Pro 64-bit, 24H2, 2009) [3,2s]

�[32m[✓]�[39m Android toolchain - develop for Android devices (Android SDK version 36.0.0) [6,4s]
    �[32m•�[39m Android SDK at C:\Users\roarg\AppData\Local\Android\Sdk
    �[32m•�[39m Emulator version 36.2.3.0 (build_id 13865802) (CL:N/A)
    �[32m•�[39m Platform android-36, build-tools 36.0.0
    �[32m•�[39m ANDROID_HOME = C:\Users\roarg\AppData\Local\Android\Sdk
    �[32m•�[39m ANDROID_SDK_ROOT = C:\Users\roarg\AppData\Local\Android\Sdk
    �[32m•�[39m Java binary at: c:\program files\java\jdk-21\bin\java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    �[32m•�[39m Java version Java(TM) SE Runtime Environment (build 21.0.8+12-LTS-250)
    �[32m•�[39m All Android licenses accepted.

�[32m[✓]�[39m Chrome - develop for the web [204ms]
    �[32m•�[39m Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

�[32m[✓]�[39m Visual Studio - develop Windows apps (Visual Studio Community 2019 16.11.50) [203ms]
    �[32m•�[39m Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    �[32m•�[39m Visual Studio Community 2019 version 16.11.36324.18
    �[32m•�[39m Windows 10 SDK version 10.0.19041.0

�[32m[✓]�[39m Connected device (3 available) [409ms]
    �[32m•�[39m Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26100.4946]
    �[32m•�[39m Chrome (web)      • chrome  • web-javascript • Google Chrome 139.0.7258.67
    �[32m•�[39m Edge (web)        • edge    • web-javascript • Microsoft Edge 139.0.3405.86

�[32m[✓]�[39m Network resources [316ms]
    �[32m•�[39m All expected network resources are available.

�[32m•�[39m No issues found!

Flutter Application Metadata

Type: malformed
Version: 0.0.1
Material: true
Android X: false
Module: false
Plugin: false
Android package: null
iOS bundle identifier: null
Creation channel: null
Creation framework version: null

Activity

  1. darshankawar commented on Aug 18, 2025

    @darshankawar
    Member

    Labeling based on the report and crash log, as this seems to be a new instance. A similar issue was reported waiting OP's response, but I'll label this for team's tracking.

  2. added
    a: widget previewsIssues related to the Widget Previewer tooling
    toolAffects the "flutter" command-line tool. See also t: labels.
    team-toolOwned by Flutter Tool team
    c: crashStack traces logged to the console
    and removed
    in triagePresently being triaged by the triage team
    on Aug 18, 2025
  3. self-assigned this
    on Aug 18, 2025
  4. added
    P2Important issues not at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    on Aug 18, 2025
  5. bkonyi commented on Aug 18, 2025

    @bkonyi
    Contributor

    Hi @RoarGronmo, thanks for trying out widget previews and filing this issue!

    Could you share some details around when you saw this crash? Were you closing the widget previewer or killing the flutter widget-preview start instance?

  6. bkonyi commented on Aug 18, 2025

    @bkonyi
    Contributor

    Looking at the crash reports, it looks like this is only happening to Windows users. It looks like this is a known issue with the directory watcher on Windows and that it's safe to ignore this exception based on this old PR: dart-archive/watcher#75.

    The fix here should be as simple as adding an onError handler to the directory watcher listen(...) call.

  7. changed the title [-][tool_crash] FileSystemException: Directory watcher closed unexpectedly, null[/-] [+][ Widget Previews ] `Watcher` stream subscription should handle `Directory watcher closed unexpectedly` exception on Windows[/+] on Aug 18, 2025
  8. RoarGronmo commented on Aug 18, 2025

    @RoarGronmo
    Author

    As I remember, I tried it on a class (StatefulWidget), it crashed, and a link appeared and I copied that link suggested and this report was filed.

    I tried it on an ordinary Widget as well, but cannot remember just what happened at the moment.

    BTW, I wish for StatelessWidgets and StatefulWidgets to be viewable in the preview, and where we could prefill values to be used, just like "ComposePreview" in kotlin/compose.

  9. 6 remaining items

  10. github-actions commented on Sep 2, 2025

    @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.

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

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: widget previewsIssues related to the Widget Previewer toolingc: crashStack traces logged to the consoler: fixedIssue is closed as already fixed in a newer versionteam-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