From 3efe06077e708be1b5ad9ac61dc700b8c7fe9e39 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Fri, 5 Dec 2014 14:23:10 +0100 Subject: [PATCH] fs: fix fd leak on early readstream destroy --- lib/fs.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/fs.js b/lib/fs.js index 85bfe2b630825f..8f661c14c1955f 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1523,6 +1523,9 @@ ReadStream.prototype.open = function() { return; } + if (self.destroyed && !self.closed) + self.close() + self.fd = fd; self.emit('open', fd); // start the flow of data.