-
Notifications
You must be signed in to change notification settings - Fork 7.3k
http: EMFILE, Too many open files #793
Comments
Yes, you need to handle those. Here's how I do it in npm: On Wed, Mar 16, 2011 at 00:13, wildchild
|
we should probably have an async function for allocating a fd. reopening |
for servers we just wait until an fd is available before accepting new connections - i think this is friendly. for clients we can give them some amount of time during connect to allocate a fd - otherwise we fail by emitting 'error'. (in the same timeout that we wait for name resolution) also warning should be printed to stdout that we're low on FDs like we do with servers. I think we can handle disk FDs similarly? |
I met the same problem whenever I start the server for more than 1 minuts, though I did not open too many connections. I am using the following modules: sequelize, socket.io, and connect. I guess the problem is inside such modules, but do not have a way to test it. Could you provide any hint to help me figure out where the problem exists? |
I've since spun graceful-fs off as its own library. https://github.com/isaacs/node-graceful-fs It'd be very easy to repurpose this to node-core. |
i'm of the opinion that we should fail fs ops on EMFILE |
@wildchild I'm using very similar code and am experiencing the exact same issue. Did you manage to resolve this EMFILE issue? net_legacy.js:747
self.fd = socket(self.type);
^
Error: EMFILE, Too many open files
at net_legacy.js:747:19
at Object.lookup (dns_legacy.js:159:5)
at Socket.connect (net_legacy.js:729:20)
at Object.createConnection (net_legacy.js:268:5)
at EventEmitter.connect (/home/hynese/Desktop/node_modules/dnode/index.js:42:26)
at Function.connect (/home/hynese/Desktop/node_modules/dnode/index.js:262:22)
at updateRemoteHash (/home/hynese/Desktop/server.js:86:9)
at Socket.<anonymous> (/home/hynese/Desktop/server.js:39:8)
at Socket.emit (events.js:67:17)
at Socket._onReadable (net_legacy.js:684:14) |
@hypense nope, just increased limits. But this is bad idea. I believe there should be a solution in core. |
I'm getting this one too. If Isaac's solution were thought of as just "the node way of blocking in a situation where there isn't really any other choice", would that make it more core-worthy? Just asking ... not taking a position either way. |
@sleeplessinc You can just use graceful-fs if you want to back off on fs EMFILE errors rather than abort. It's been working well for npm. This shouldn't be in core. |
Agreed. I think a note in the docs near the synch fs functions may be in order though, no? |
but when using graceful-fs and another module uses plain fs you're screwed again |
Such is life. I think we forgot to close this issue. Closing then. |
I think We should re-open the issue. graceful-fs does NOT solve it actually, yet it does wrap the error so the EMFILE is not emitted ;)... i've been using both graceful and non-graceful, getting :error on readstream:Error: EMFILE, open found n steady way to reproduce the error: using centos linux / nodejs 10.0.15 |
The following code fails with "Too many open files". Just run it, change proxy settings for your browser and point it to one of the sites with millions of banners, do a number of refreshes.
Fails after a huge number of requests with:
node 0.4.2 on OSX 10.6
The text was updated successfully, but these errors were encountered: