Skip to content

Commit

Permalink
fix: use pipeline to propagate errors across all piped streams (#288)
Browse files Browse the repository at this point in the history
Co-authored-by: Ziggy Jonsson <ziggy.jonsson.nyc@gmail.com>
  • Loading branch information
oaleynik and ZJONSSON authored Apr 14, 2024
1 parent 7c4604e commit d7f01ee
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var NoopStream = require('./NoopStream');
var BufferStream = require('./BufferStream');
var parseExtraField = require('./parseExtraField');
var parseDateTime = require('./parseDateTime');
var pipeline = Stream.pipeline;
var parseBuffer = require('./parseBuffer');

var endDirectorySignature = Buffer.alloc(4);
Expand Down Expand Up @@ -187,13 +188,18 @@ Parse.prototype._readFile = function () {
}

return new Promise(function(resolve, reject) {
self.stream(eof)
.pipe(inflater)
.on('error',function(err) { self.emit('error',err);})
.pipe(entry)
.on('finish', function() {
pipeline(
self.stream(eof),
inflater,
entry,
function (err) {
if (err) {
return reject(err);
}

return fileSizeKnown ? resolve(fileSizeKnown) : self._processDataDescriptor(entry).then(resolve).catch(reject);
});
}
)
});
});
});
Expand Down

0 comments on commit d7f01ee

Please sign in to comment.