Explicitly close the stream once finished reading

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

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

Loading…
Cancel
Save