Bug 28693 - IOException: kqueue() FileSystemWatcher has reached the maximum nunmber of files to watch.
Summary: IOException: kqueue() FileSystemWatcher has reached the maximum nunmber of fi...
Status: VERIFIED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 3.12.0
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-04-02 11:56 UTC by David Fowler
Modified: 2015-12-17 11:36 UTC (History)
10 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description David Fowler 2015-04-02 11:56:55 UTC
1. Clone `https://github.com/anurse/dnxb4signoff`
2. `cd src\DnxSignoff`
3. `dnu restore`
4. `dnx . kestrel`
5. :(

Expected: Pretty MVC stuff

Actual:
![screen shot 2015-04-01 at 4 38 13 pm](https://cloud.githubusercontent.com/assets/7574/6955030/856cd5dc-d88d-11e4-98e0-0e62a9529401.png)
Comment 1 Michiel Staessen 2015-04-06 05:11:48 UTC
Also present in MDK 4.0.0
Comment 2 Miguel de Icaza [MSFT] 2015-04-07 18:09:57 UTC
We need a better repro than using dnu restore/dnx kestrel because those stacks are too large and I have failed repeatedly at getting them working with my custom build of Mono.

The resources on the web are also lacking.
Comment 3 Suhas 2015-04-30 14:29:18 UTC
Users are hitting this with 4.0.1 as well. More info at https://github.com/aspnet/Home/issues/508
Comment 4 sornakumar 2015-08-06 14:02:32 UTC
@Miquel de Icaza - https://github.com/aspnet/Home/issues/508#issuecomment-122305412 This comment mentions the scenario can be repro'd using Gulp and Sass.

Is dnu restore/dnx kestrel still not working for you? I can help you get them working if you give me the error you are encountering..
Comment 5 Chris F Carroll 2015-09-01 18:09:00 UTC
To reproduce this on OS X / Mono 4:
===============
using System;
using System.IO;
public class WatcherFileLimit
{
    public static void Main()
    {
        FileSystemWatcher watcher = new FileSystemWatcher();
        watcher.Path = "/";
        watcher.IncludeSubdirectories=true;
        watcher.EnableRaisingEvents = true;
    }
}
===============
whereas the equivalent on .Net on Windows 10 (i.e. watcher.Path="\\") works fine.
Comment 6 Chris F Carroll 2015-09-01 18:15:31 UTC
Sorry let me be more precise. That was with mono version 4.2.0.

Reproduce it in the csharp repl with the lines:
---
using System.IO;
var w= new FileSystemWatcher{Path="/", IncludeSubdirectories=true, EnableRaisingEvents=true};
----

If you omit EnableRaisingEvents, then it doesn't throw.
Comment 7 Nate Cook 2015-12-04 20:42:52 UTC
I get this using dnx-watch kestrel. Running dnx kestrel works fine.

https://github.com/aspnet/dnx-watch/issues/13
Comment 8 Nate Cook 2015-12-04 20:51:28 UTC
In my case the workaround was to put my code into a src folder and run dnx-watch there instead of at the root. The result of that was the exclusion of the .git folder in the root, which I assume was the problem since my project is quite small at this point.
Comment 9 Miguel Lira 2015-12-05 11:58:18 UTC
It appears there is hard coded max value of 200 for the number of dictionary entries that can be added to the watcher:

https://github.com/mono/mono/blob/b7a308f660de8174b64697a422abfc7315d07b8c/mcs/class/System/System.IO/KeventWatcher.cs#L641

Once exceeded the exception is thrown:

https://github.com/mono/mono/blob/b7a308f660de8174b64697a422abfc7315d07b8c/mcs/class/System/System.IO/KeventWatcher.cs#L444

Most .NET 5/MVC 6 developers will run into this limit due to the large number of files added to the bower_components and npm_modules folders.

This is most likely a limit imposed for some performance reason, but it would be great if someone on the Mono team could provide more feedback.
Comment 10 Miguel de Icaza [MSFT] 2015-12-09 00:29:26 UTC
Fixed, the limit is gone.
Comment 11 Shruti 2015-12-17 11:36:09 UTC
I have checked this issue with latest C6SR1 Mono  MonoFramework-MDK-4.2.2.18.macos10.xamarin.x86_d35418ca2aa7a45a882d6df7a63a371f0d10e251 using code snippet given in comment(5) and observed that Now no exception is raising on watcher.EnableRaisingEvents = true. 

Screencast: http://www.screencast.com/t/Jyr3Zc31r7

Environment Info:https://gist.github.com/shrutis360/3d269a8dede0da9640ad


Hence, Closing this issue.

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Note You need to log in before you can comment on or make changes to this bug.