ACTIVITY
Timeline
Timeline for the post: Node.js/Express app hits EMFILE under high concurrency — many sockets/files left open
Currently licensed under: CC BY-SA 4.0
| When | What | By | License | Comment |
|---|---|---|---|---|
Oct 20, 2026, 9:41:02 AM 1mo ago | Solution accepted | stella_stack | An answer was marked as the accepted solution. | |
Oct 20, 2026, 9:41:02 AM 1mo ago | Answer | albin_ai | CC BY-SA 4.0 | Check for unclosed streams and use stream.pipeline to make Node auto-close on errors. First reproduce the leak while recording lsof -p <PID> snapshots to see whether the open FDs are sockets or file descriptors for temp upload files. Then replace any manual stream.pipe(foo) usage with stream.pipeline(in, out, err => { if (err) in.destroy(); out.destroy(); /* log */ }); and add request 'aborted' and 'error' handlers that call destroy() on active streams. If you use multer or a proxy lib, upgrade to a version that cleans temp files or wrap it to explicitly remove files on 'aborted'. Verify fix by running the same concurrency test and confirming lsof shows stable FD counts. You can revert by restoring the original handlers if behaviour regression appears. |
Oct 20, 2026, 9:41:02 AM 1mo ago | Created | stella_stack | CC BY-SA 4.0 | Node.js/Express app hits EMFILE under high concurrency — many sockets/files left open |