Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Express Error: EMFILE, too many open files

Express Error: EMFILE, too many open files

Problem

I am getting the following very annoying error:

Error: EMFILE, too many open files '/home/savagegames.net/views/index.jade'
at Object.openSync (fs.js:240:18)
at Object.readFileSync (fs.js:128:15)
at View.contents (/home/savagegames.net/node_modules/express/lib/view/view.js:121:13)
at Function.compile (/home/savagegames.net/node_modules/express/lib/view.js:68:45)
at ServerResponse._render (/home/savagegames.net/node_modules/express/lib/view.js:417:18)
at ServerResponse. (/home/savagegames.net/node_modules/express/lib/view.js:318:17)
at /home/savagegames.net/node_modules/express-mongoose/index.js:45:21
at resolve (/home/savagegames.net/node_modules/express-mongoose/index.js:75:12)
at ServerResponse.expressmongoose [as render] (/home/savagegames.net/node_modules/express-mongoose/index.js:37:12)
at /home/savagegames.net/controllers/index_controller.coffee:49:18

I believe it is a problem with Express; how can I remedy it? Thanks.

Problem courtesy of: Ian Macalinao

Solution

From what I found, it happens when some error happens, and some files aren't closed (of course this is a bug). In my case, node-postgres errors caused (miracleously) depletion of available descriptors. When I removed the code that caused db error, the EMFILE dissapears.

I suppose it could be fixed in the node.js code - it should close file objects when garbage collecting. Though it might happen that these lost file descriptors are still locked alive by something else.

Solution courtesy of: sergeych

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Express Error: EMFILE, too many open files

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×