Closed RB-93 closed 2 years ago
@DanTup , have you seen this before?
I haven't seen it in this context before. I believe that error text is what occurs when Dart/package:watcher
is watching a directory that is deleted, although it doesn't seem like the path in the message here should be deleted during a build so it could be something else.
@RB-93 does this occur only for this project, or does it also reproduce if you create an empty project using Flutter: New Project?
If it's only this project, are you able to trim it down to something you can share that still triggers the issue?
I have this issue after deleting the whole build folder. I tried to reload the IDE and build it again, it works now.
@kevinxxq can you reproduce this? Does it occur just when you delete the build
folder while the editor is open?
Hi Danny, I just trided again, it didn't take place again. Yes, the eidtor is open. Thank you.
Hi @DanTup I've been encountering this same issue since after 18th June as far as I can remember.
In M1 and Win 11 both, in all of the flutter projects.
It occurred this time when I cloned ran for the first time using VSC, closed the app instance from my phone's recents screen. And started debug mode again.
Edit:
After closing the project folder, restarting the VSC, reopening the project folder in debug mode encountered the same error again.
On restarting the machine, did not see it again for Win11. Even on closing the app from the my phone or deleting the build folder while the app is running in debug mode. Thank you
@alphapokedex
On restarting the machine, did not see it again for Win11.
Do you mean you can no longer reproduce it with the same project? If you can, does it occur only with that project, or also with a new project created with the Flutter: New Project command? If not, could you share the pubspec of the project that does trigger it?
Can you also confirm if the error message exactly the same when it occurs on macOS, or different?
Hi @DanTup I encountered this issue for the same project right now.
I had just booted up my machine and started VSC for this project, after few seconds of debug session startup...
I checked the outputs section
[Error - 9:32:22 am] Socket error: FileSystemException: Directory watcher closed unexpectedly, path = 'c:\Users\alpha\Documents\GitHub\Spidr': FileSystemException: Directory watcher closed unexpectedly, path = 'c:\Users\alpha\Documents\GitHub\Spidr'
#0 _FileSystemWatcher._listenOnSocket.<anonymous closure> (dart:io-patch/file_patch.dart:354:11)
#1 _ExpandStream._handleData (dart:async/stream_pipe.dart:232:30)
#2 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#3 _rootRunUnary (dart:async/zone.dart:1442:13)
#4 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#5 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#8 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#9 _StreamController._add (dart:async/stream_controller.dart:648:7)
#10 _StreamController.add (dart:async/stream_controller.dart:596:5)
#11 new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1846:35)
#12 _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1315:18)
#13 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#14 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#15 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:122:13)
#16 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:193:5)
I'll try to recreate with the new project as well. Here is my flutter doctor -v
alpha@Chirag MINGW64 ~/Documents/GitHub/Spidr (shivam)
$ flutter doctor -v
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.22000.739], locale en-IN)
• Flutter version 3.0.5 at C:\Users\alpha\Documents\GitHub\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f1875d570e (34 hours ago), 2022-07-13 11:24:16 -0700
• Engine revision e85ea0e79c
• Dart version 2.17.6
• DevTools version 2.12.2
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\alpha\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
[√] VS Code (version 1.69.1)
• VS Code at C:\Users\alpha\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.44.0
[√] Connected device (4 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.739]
• Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.114
• Edge (web) • edge • web-javascript • Microsoft Edge 103.0.1264.49
[√] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
Yes the error message is exactly the same for all the devices, I've noticed for my colleague's VSC as well. Thank you
@alphapokedex if you can repro this in a clean new project, could you try the following in the new project:
"dart.analyzerInstrumentationLogFile": "logs/analyzer.txt",
inside the JSON objectlogs/analyzer.txt
file created in your projectHi @DanTup I was unable to find exact steps to reproduce this issue every time, but here are the steps to reproduce it occasionally.
Run Flutter: New Project from VSC Command Palette.
Create a clean flutter project.
Update the pubspec.yaml
cloud_firestore: ^3.1.18
country_code_picker: ^2.0.1
dio: ^4.0.6
firebase_auth: ^3.4.2
firebase_storage: ^10.3.2
firebase_core: ^1.19.2
flutter_bluetooth_serial: ^0.4.0
firebase_database: ^9.0.19
flutter_pin_code_fields: ^1.1.0
flutter_riverpod: ^1.0.4
flutter_svg: ^1.1.1+1
fluttertoast: ^8.0.9
font_awesome_flutter: ^10.1.0
google_fonts: ^3.0.1
hive: ^2.2.3
hive_flutter: ^1.1.0
image: ^3.2.0
image_cropper: ^2.0.3
image_picker: ^0.8.5+3
geolocator: ^9.0.1
modal_progress_hud: ^0.1.3
path_provider: ^2.0.11
permission_handler: ^10.0.0
shared_preferences: ^2.0.15
uuid: ^3.0.6
syncfusion_flutter_charts: ^20.2.38
intl: ^0.17.0
permission: ^0.1.7
csv: ^5.0.1
share: ^2.0.4
filesystem_picker: ^2.0.1
geocoding: ^2.0.4
app_settings: ^4.1.8
flutter_typeahead: ^4.0.0
firebase_messaging: ^12.0.0
sqflite: ^2.0.3
provider: ^6.0.3
horizontal_data_table: ^4.1.1+1
syncfusion_flutter_gauges: ^20.2.38
url_launcher: ^6.0.20
timeago: ^3.2.2
android_intent_plus: ^3.1.1
logger: ^1.1.0
flutter_timer_countdown: ^1.0.3
Update minSdkVersion to 19
Run flutter pub get
Press F5
or Start project in debug mode.
After the application successfully starts up in your device.
Terminate the debug mode.
Run flutter clean && exit
Close project folder.
Close all VSC windows.
Open VSC & open the same project.
Press F5
or Start project in debug mode.
You'll see a message box with Socket error: FileSystemException: Directory watcher closed unexpectedly
message.
here is the gist for analyzer.txt
Hope you are able to see the same on your machine.
Thank you
@alphapokedex thanks! I seem to be able to reproduce this somehwat intermittently. I'm using a test app as you described, and then running
F5
to runThe app won't actually run for me (weird Gradle errors), but during the attempts to build it seems to trigger this. I can repro running the analysis server from source and the same steps, so this should make it easier to track down. Thanks!
Ok, I believe I understand what's happening. When Flutter builds it modifies a lot of files on disk in a short space of time and this sometimes overflows the watcher and causes it to close. The server has code to handle this (it creates new watchers and reanalyzes from disk), however to resolve some other issues during the restart it creates some additional watchers which do not have error handling (and since the Flutter build may still be occurring, it's possible those will close for the same reason).
I have a fix to handle these errors that seems to have eliminated the issue for me. It's not ideal that a Flutter build can touch enough files to overflow the watcher and require a restart like this, but I believe that's understood behaviour because the server has had to handle this before (@bwilkerson @scheglov FYI).
Whenever I try to run or build my project, the above issue occurs. (see screenshot)
The build/ directory gets updated which is usually normal.
But the issue causes the build time to get longer.
Flutter Doctor output: flutter doctor -v [√] Flutter (Channel stable, 3.0.2, on Microsoft Windows [Version 10.0.19044.1706], locale en-IN) • Flutter version 3.0.2 at C:\Users\rohit\Documents\Flutter SDK\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision cd41fdd495 (9 days ago), 2022-06-08 09:52:13 -0700 • Engine revision f15f824b57 • Dart version 2.17.3
• DevTools version 2.12.2
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at C:\Users\rohit\AppData\Local\Android\sdk • Platform android-32, build-tools 31.0.0 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840) • All Android licenses accepted.
[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.15) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools • Visual Studio Build Tools 2019 version 16.11.32510.428 • Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.2) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
[√] VS Code (version 1.68.0) • VS Code at C:\Users\rohit\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.42.0
[√] Connected device (4 available) • Moto Z2 Play (mobile) • 192.168.29.253:5555 • android-arm • Android 8.0.0 (API 26) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1706] • Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.63 • Edge (web) • edge • web-javascript • Microsoft Edge 102.0.1245.41
[√] HTTP Host Availability • All required HTTP hosts are available
• No issues found!
Originally posted by @RB-93 in https://github.com/dart-lang/sdk/issues/38853#issuecomment-1158531992