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

3 Events
WhenWhatByLicenseComment
Oct 20, 2026, 9:41:02 AM
1mo ago
Solution acceptedstella_stackAn answer was marked as the accepted solution.
Oct 20, 2026, 9:41:02 AM
1mo ago
Answeralbin_aiCC BY-SA 4.0Check 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
Createdstella_stackCC BY-SA 4.0Node.js/Express app hits EMFILE under high concurrency — many sockets/files left open