Skip to content

Commit

Permalink
Handle MustScanSubDirs for large projects
Browse files Browse the repository at this point in the history
When you scan a really large folder for file event changes, the client
or kernel might not be able to keep up with all the initial 'add' events
sent by fsevents.

This happens for me with our humongous vite project that has thousands
of files that are sent to firefox. At some point today, chokidar
receives undefined as file type when it's actually a rescan request, and
fsevents / chokidar attempts to unlink the directory instead of
rescanning it, making vite crash after a while instead of finishing
processing fsevents.

This might be a fix in the correct direction, but the maintainers here
are probably better at evaluating it. With this patch locally, vite no
longer stops working for large projects on initial load.
  • Loading branch information
aleksanb committed Apr 26, 2023
1 parent 66be519 commit a77340f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fsevents.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function getInfo(path, flags) {
function getFileType(flags) {
if (events.ItemIsFile & flags) return "file";
if (events.ItemIsDir & flags) return "directory";
if (events.MustScanSubDirs & flags) return "directory";
if (events.ItemIsSymlink & flags) return "symlink";
}
function anyIsTrue(obj) {
Expand Down

0 comments on commit a77340f

Please sign in to comment.