Open rajatraj733 opened 4 years ago
As I wanted to use just decompress method hence, I avoided this issue by:
import decompress from 'brotli/decompress'
Now, I got into another issue:
index.js:1 Error: [ReadHuffmanCode] invalid num_codes or space
at ReadHuffmanCode (decode.js:323)
at HuffmanTreeGroup.push../node_modules/brotli/dec/decode.js.HuffmanTreeGroup.decode (decode.js:392)
at BrotliDecompress (decode.js:747)
at BrotliDecompressBuffer (decode.js:583)
at _callee$ (appActions.js:104)
I'm pretty sure there is no space in the compressed string.
Had the same issue so ended up using the nodejs builtin zlib library
For me, I found that I got this error when I inadvertently passed an ArrayBuffer
to decompress
instead of a Buffer
.
I used Buffer.from
(https://www.npmjs.com/package/buffer) to create a Buffer from the ArrayBuffer first, then the decompress
function worked.
compress
const foo = compress(Buffer.from(str));
decompress
const arrayBuff = decompress(Buffer.from(foo));
const str = Buffer.from(arrayBuff).toString("utf-8");
I ran into this as well and the solution was to pass Buffer.from(compressed, 'binary')
the second argument 'binary'
I'm using brotli with react version 16.13. By just import brotli in react component file shows this error. This is the error stack:
Brotli version - 1.3.2