Build Issue

krenar-telosPRO

8 months ago

Hi support,

I am getting the error below. Even if I redeploy the version that worked, it still crashes with this error after the deployment, on top of the first build failing on the first time. What can we do to fix this?

node:internal/errors:496

ErrorCaptureStackTrace(err);

Error: EMFILE: too many open files, watch '/app/src/mail/templates'

at FSWatcher.<computed> (node:internal/fs/watchers:247:19)

at Object.watch (node:fs:2418:34)

at createFsWatchInstance (/app/node_modules/chokidar/lib/nodefs-handler.js:119:15)

at setFsWatchListener (/app/node_modules/chokidar/lib/nodefs-handler.js:166:15)

at NodeFsHandler._watchWithNodeFs (/app/node_modules/chokidar/lib/nodefs-handler.js:331:14)

at NodeFsHandler._handleDir (/app/node_modules/chokidar/lib/nodefs-handler.js:567:19)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

at async NodeFsHandler._addToNodeFs (/app/node_modules/chokidar/lib/nodefs-handler.js:617:16)

at async /app/node_modules/chokidar/index.js:451:21

at async Promise.all (index 0)

Emitted 'error' event on FSWatcher instance at:

at FSWatcher._handleError (/app/node_modules/chokidar/index.js:647:10)

at NodeFsHandler._addToNodeFs (/app/node_modules/chokidar/lib/nodefs-handler.js:645:18)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

at async /app/node_modules/chokidar/index.js:451:21

at async Promise.all (index 0) {

errno: -24,

syscall: 'watch',

code: 'EMFILE',

path: '/app/src/mail/templates',

filename: '/app/src/mail/templates'

}

Node.js v18.20.2

This is a common issue in environments where many files are being watched, such as with chokidar in a Node.js application.

How can I resolve that issue? Can we Increase the limit of open files:

  • On Unix-based systems, you can increase the limit temporarily by running:

Plain Text

ulimit -n 2048
  • To make this change permanent, you can add the following lines to your shell configuration file (e.g., .bashrc, .zshrc):

Plain Text

echo "ulimit -n 2048" >> ~/.bashrcsource ~/.bashrc
Solved

4 Replies

chandrikaEMPLOYEE

8 months ago

Hi there , I've asked the team about this so we'll look into it. I'll update you here as soon as we know!


Status changed to Awaiting User Response railway[bot] 8 months ago


ioo52987HOBBY

7 months ago

Same issue on mine


Status changed to Awaiting Railway Response railway[bot] 7 months ago


7 months ago

Unfortunately you cannot use this many watchers. What is the usecase? It's likely you're deploying dev server config to production


Status changed to Awaiting User Response railway[bot] 7 months ago


krenar-telosPRO

7 months ago

Fixed: The issue with Error: EMFILE: too many open files, watch '/app/src/mail/templates' was resolved by reducing the number of open files. Additionally, it appears that the package “puppeteer”: “^22.0.0” might have contributed to the problem. Here are some steps that helped:

  1. Reduced Open Files: Limiting the number of files being watched helped stay within system limits.

  2. Puppeteer Management: Ensuring Puppeteer instances are properly closed after use to prevent file descriptor leaks:

    const browser = await puppeteer.launch();
    // ... your code ...
    await browser.close();
    

These adjustments improved the stability and resolved the EMFILE error.


Status changed to Awaiting Railway Response railway[bot] 7 months ago


Status changed to Solved brody 7 months ago


Build Issue - Railway Help Station