regular / unbzip2-stream

streaming unbzip2 implementatio in pure javascript for node and browsers
Other
29 stars 23 forks source link

TypeError, possibly due to corrupt stream #3

Closed atombender closed 8 years ago

atombender commented 8 years ago

There's a possibility that my data is corrupt. Regardless, the stream shouldn't throw a random error like this.

TypeError: Cannot read property '0' of undefined
   at f (/tmp/app/node_modules/unbzip2-stream/lib/bit_iterator.js:24:34)
   at Object.bzip2.decompress (/tmp/app/node_modules/unbzip2-stream/lib/bzip2.js:272:13)
   at decompressBlock (/tmp/app/node_modules/unbzip2-stream/index.js:29:28)
   at decompressAndQueue (/tmp/app/node_modules/unbzip2-stream/index.js:46:20)
   at Stream.end (/tmp/app/node_modules/unbzip2-stream/index.js:86:23)
   at _end (/tmp/app/node_modules/unbzip2-stream/node_modules/through/index.js:65:9)
   at Stream.stream.end (/tmp/app/node_modules/unbzip2-stream/node_modules/through/index.js:74:5)
   at PassThrough.onend (_stream_readable.js:501:10)
   at PassThrough.g (events.js:180:16)
   at PassThrough.emit (events.js:117:20)
   at _stream_readable.js:943:16
   at process._tickDomainCallback (node.js:463:13)
regular commented 8 years ago

Can you upload the offending file somewhere? Will be hard to reproduce otherwise.

atombender commented 8 years ago

Unfortunately, it happens seemingly randomly among a huge load of files archived on S3. I've since moved to a native bzip2 NPM module, since yours proved to be about 10x slower than native.

tedbrandston commented 8 years ago

I'm seeing the same thing for basically any truncated bz2 file I make. There will be slight differences in the location in bzip2.js (line 272, line 277, etc.) depending on exactly where the file is cut off.

tedbrandston commented 8 years ago

looks like it's because of the filtering of Bzip2Errors from other errors here. Looks like it's been broken since the initial commit?

Not sure if there's a good reason to do it that way, so I'll put in a pull request.

@atombender what did you end up switching to?

atombender commented 8 years ago

@tedbrandston: Switched to this. No complaints so far.

regular commented 8 years ago

Fixed in 1.0.10