isaacs / sax-js

A sax style parser for JS
Other
1.09k stars 325 forks source link

Problems with V10 #247

Open martinfranz opened 4 years ago

martinfranz commented 4 years ago

Hi, with node V10 (maybe even earlier versions), SAXStream is not signaling an end. So: await pipeline( fs.createReadStream(fileName, 'utf8'), parser ) console.log('finish') will never reach "finish". I'm not a master of node streams, just created some write streams. I could fix that issue (at least for my use case) by changing to Stream = require('stream').Writable, deleting the SAXStream.prototype.end function and used SAXStream.prototype._final = function (cb) { this._parser.end() if (cb) cb() } Maybe somebody with better knowledge about node streams could fix the original sax code. At least, my simple fix resolved that particular issue... Best regards, Martin

georgyfarniev commented 4 years ago

@martinfranz I'm suspecting it's because parser emitting only 'end' event, but not 'finish' as expected by pipeline function.

WouterVanheeswijk-TomTom commented 2 years ago

Had the same issue, I'm using this work-around:

parser.once('end', () => parser.emit('finish'))