Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error: -3" when inflating chunks of data #265

Open
ceffiong opened this issue Nov 19, 2022 · 2 comments
Open

"Error: -3" when inflating chunks of data #265

ceffiong opened this issue Nov 19, 2022 · 2 comments

Comments

@ceffiong
Copy link

I'm trying to uncompress a .zg file in chunks following the example in the documentation: https://nodeca.github.io/pako/#Inflate.prototype.push but run into error. Could you help me understand and resolve this error?

Browser console output

Response {type: 'basic', url: 'https:/****.rpt.gz', redirected: false, status: 200, ok: true, …}
detail.js:48 ArrayBuffer(29235)
detail.js:49 29235
detail.js:54 ArrayBuffer(8000)
detail.js:54 ArrayBuffer(8000)
detail.js:54 ArrayBuffer(8000)
detail.js:54 ArrayBuffer(5235)
detail.js:57 last chunk
detail.js:64 something is wrong
detail.js:78 Error: -3
at readReport (detail.js:65:10)

Source code

console.log(buf)
console.log(buf.byteLength)
const chunkSize = 8000
var inflate = new pako.Inflate({to: "string"})
for(let i = 0; i < buf.byteLength; i+= chunkSize){
    const chunk = buf.slice(i, i + chunkSize);
    console.log(chunk)
    if(i + chunkSize >= buf.byteLength){
	  inflate.push(chunk, true)
	  console.log("last chunk")
    }else{
	  inflate.push(chunk, false)
    }	
}
if(inflate.err){
    console.log("something is wrong")
    throw new Error(inflate.err)
}
console.log(inflate.result)

Note: I'm doing chunk because I get a "distance too far back error" which I understand means the file is too big to be inflated at once.

Looking forward to your reply,
Charles

@ceffiong
Copy link
Author

I console.log out the inflate object just before the error check and saw the following outputs:

ra {options: {…}, err: -3, msg: 'invalid distance too far back', ended: true, chunks: Array(0), …}
chunks: []
ended: true
err: -3
header: Je {text: 0, time: 0, xflags: 0, os: 0, extra: null, …}
msg: "invalid distance too far back"
options: {chunkSize: 65536, windowBits: -15, to: '', level: 3, raw: true}
strm: qt {input: Uint8Array(8), next_in: 4, avail_in: 4, total_in: 52, output: Uint8Array(65536), …}
[[Prototype]]: Object

Still got "invalid distance too far back" error. Next, I included chunkSize in the pako init e.g. "var inflate = new pako.Inflate({to: "string", chunkSize:8})" but the error persists.

I'm not sure what am doing wrong.

Regards,

@jammerxd
Copy link

jammerxd commented Jul 13, 2023

I'm having this issue as well. Did you ever figure it out? I need a javascript library for zlib or gzip that can produce the same binary results as the c++ library (for strings/buffers).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants