Skip to content
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

Error: EMFILE: too many open files #271

Open
trebeljahr opened this issue Dec 18, 2024 · 1 comment
Open

Error: EMFILE: too many open files #271

trebeljahr opened this issue Dec 18, 2024 · 1 comment

Comments

@trebeljahr
Copy link

trebeljahr commented Dec 18, 2024

I am encountering an error with velite's watchmode during npm run dev.

The full stack trace

Error: EMFILE: too many open files, watch '/Users/rico/projects/trebeljahr.com/src/content/Notes/assets/midjourney-gallery/Trebeljahr_an_impressionistic_painting_of_a_beautiful_flower_ga_ae6f3c9a-4729-42b4-bbc3-bd582fd87dbe.webp'
 at FSWatcher.<computed> (node:internal/fs/watchers:247:19)
    at watch (node:fs:2473:36)
    at createFsWatchInstance (file:///Users/rico/projects/trebeljahr.com/node_modules/velite/dist/velite-CMIMbt4v.js:354:16)
    at setFsWatchListener (file:///Users/rico/projects/trebeljahr.com/node_modules/velite/dist/velite-CMIMbt4v.js:399:19)
    at NodeFsHandler._watchWithNodeFs (file:///Users/rico/projects/trebeljahr.com/node_modules/velite/dist/velite-CMIMbt4v.js:553:22)
    at NodeFsHandler._handleFile (file:///Users/rico/projects/trebeljahr.com/node_modules/velite/dist/velite-CMIMbt4v.js:619:29)
    at NodeFsHandler._addToNodeFs (file:///Users/rico/projects/trebeljahr.com/node_modules/velite/dist/velite-CMIMbt4v.js:843:31)
Emitted 'error' event on FSWatcher instance at:
    at FSWatcher._handleError (file:///Users/rico/projects/trebeljahr.com/node_modules/velite/dist/velite-CMIMbt4v.js:1384:18)
    at NodeFsHandler._addToNodeFs (file:///Users/rico/projects/trebeljahr.com/node_modules/velite/dist/velite-CMIMbt4v.js:851:26) {
  errno: -24,
  syscall: 'watch',
  code: 'EMFILE',
  path: '/Users/rico/projects/trebeljahr.com/src/content/Notes/assets/midjourney-gallery/Trebeljahr_an_impressionistic_painting_of_a_beautiful_flower_ga_ae6f3c9a-4729-42b4-bbc3-bd582fd87dbe.webp',
  filename: '/Users/rico/projects/trebeljahr.com/src/content/Notes/assets/midjourney-gallery/Trebeljahr_an_impressionistic_painting_of_a_beautiful_flower_ga_ae6f3c9a-4729-42b4-bbc3-bd582fd87dbe.webp'
}

The problem seems to be that I have too many files in the content directory that velite tries to watch.

For context, I am storing around 7000 assets (mostly .jpg images) + another 500 or so content (.md) files in my Obsidian repo, that then get ingested by velite during the build/runtime process of next.js

The error disappears as soon as I temporarily move the assets out of the content directory that velite is trying to watch, in other words there seems to be a limit to the files velite can watch which is a bit annoying...

my next.js config part for running velite looks like this and is pretty much copy pasted from the docs

const isDev = process.argv.indexOf("dev") !== -1;
const isBuild = process.argv.indexOf("build") !== -1;
if (!process.env.VELITE_STARTED && (isDev || isBuild)) {
  process.env.VELITE_STARTED = "1";
  const { build } = await import("velite");
  await build({ watch: isDev, clean: !isDev, logLevel: "error" });
}

I've been trying to look into the docs for options to give to the build command, but didn't find any option to increase the "max" file watcher limit or to tell velite to ignore directories/files.

But something like that would solve the problem since I really don't need to watch the assets part of the content folder for rebuilding all the time with velite.

@zce
Copy link
Owner

zce commented Dec 20, 2024

Unfortunately, this is a bug in the upstream package.
I will try to switch to @parcel/watcher in the near future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants