Explicitly close the stream once finished reading

master
Sven Slootweg 3 years ago
parent 8bf5d8b4d2
commit 26562d874b

@ -29,7 +29,11 @@ function doRead(handle, length) {
}).then((result) => { }).then((result) => {
if (result.bytesRead === 0) { if (result.bytesRead === 0) {
// Not documented; https://github.com/nodejs/node/issues/35363 // Not documented; https://github.com/nodejs/node/issues/35363
return Promise.try(() => {
return handle.close();
}).then(() => {
throw new EndOfStream(); throw new EndOfStream();
});
} else if (result.bytesRead === length) { } else if (result.bytesRead === length) {
return buffer; return buffer;
} else if (result.bytesRead < length) { } else if (result.bytesRead < length) {

Loading…
Cancel
Save