cscott / compressjs

Pure JavaScript de/compression (bzip2, etc) for node.js, volo, and the browser.
GNU General Public License v2.0
352 stars 41 forks source link

BZip2 DecompressFile: Trace: TypeError: Cannot use 'in' operator to search for 'readByte' in <file> #18

Closed drazisil closed 6 years ago

drazisil commented 6 years ago

I'm not sure why I'm getting this error. I can upload the file somewhere if you would like, it's 8MB

node -v v8.9.4 node_modules/.bin/compressjs -V 0.0.1 Real version: 1.0.3

Here is the error:

Trace: TypeError: Cannot use 'in' operator to search for 'readByte' in cache/complete.json.bz2
    at Object.Util.coerceInputStream (/home/drazisil/github/minepack/node_modules/compressjs/lib/Util.js:10:26)
    at Object.Bunzip.decode [as decompressFile] (/home/drazisil/github/minepack/node_modules/compressjs/lib/Bzip2.js:456:26)
    at unbzip2Modlist (/home/drazisil/github/minepack/main.js:107:34)
    at /home/drazisil/github/minepack/main.js:132:11
    at tryCatcher (/home/drazisil/github/minepack/node_modules/bluebird/js/release/util.js:16:23)

Here is the code:

  var algorithm = compressjs.Bzip2;

  try {
    var decompressed = algorithm.decompressFile(compressedModlistPath);
  } catch (error) {
}
drazisil commented 6 years ago

https://github.com/cscott/compressjs/blob/f2377885d433b4de566f412f3d1089303abbd114/lib/Bzip2.js#L931

Turns out you still need to read the file, decompressFile() doesn't open it like the name suggests.

var decompressed = algorithm.decompressFile(fs.readFileSync(compressedModlistPath)); works