diff --git a/lib/big-xml.js b/lib/big-xml.js index 07472fa..3ad2f8b 100644 --- a/lib/big-xml.js +++ b/lib/big-xml.js @@ -17,8 +17,15 @@ function BigXmlReader(filename, recordRegEx, options) { var parser = new expat.Parser('UTF-8'); var stream = typeof filename === "string" ? fs.createReadStream(filename) : filename; + stream.on('error', function(err) { + self.emit('error', new Error(err)); + }); + if (options.gzip) { var gunzip = zlib.createGunzip(); + gunzip.on('error', function(err) { + self.emit('error', new Error(err)); + }); stream.pipe(gunzip); stream = gunzip; } @@ -31,10 +38,6 @@ function BigXmlReader(filename, recordRegEx, options) { } }); - stream.on('error', function(err) { - self.emit('error', new Error(err)); - }); - /////////////////////////// var node = {};