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

Update Pako library to the latest version #15

Open
alex-titarenko opened this issue Sep 19, 2022 · 1 comment
Open

Update Pako library to the latest version #15

alex-titarenko opened this issue Sep 19, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@alex-titarenko
Copy link
Contributor

alex-titarenko commented Sep 19, 2022

Apparently Pako v2.* has some breaking changes that prevent us from updating it without deep investigation.

Problematic code in this library:

inflator.push(chunk, false)
if (inflator.err) {
throw new InternalError(`Pako error: ${inflator.msg}`)
}

Problematic code on pako library:
https://github.com/nodeca/pako/blob/174a1d12b68dfbd531a572eaaea0937491b36f55/lib/inflate.js#L237-L245

// Skip snyc markers if more data follows and not raw mode
while (strm.avail_in > 0 &&
       status === Z_STREAM_END &&
       strm.state.wrap > 0 &&
       data[strm.next_in] !== 0)
{
  zlib_inflate.inflateReset(strm);
  status = zlib_inflate.inflate(strm, _flush_mode);
}

this does not exist in Pako v1.* and causes the following error in Inflator
Err: -3, msg: 'incorrect header check'

@alex-titarenko alex-titarenko added the bug Something isn't working label Sep 19, 2022
@alex-titarenko alex-titarenko added enhancement New feature or request and removed bug Something isn't working labels Oct 13, 2022
@alex-titarenko
Copy link
Contributor Author

Since CompressionStream API is not available in stable Safari we should consider instead upgrading code to use native API

async function browserInflate(buffer: Uint8Array) {
  const ds = new DecompressionStream('deflate')
  const d = (<ReadableStream><unknown>new Blob([buffer]).stream()).pipeThrough(ds)
  return new Uint8Array(await new Response(d).arrayBuffer())
}

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

No branches or pull requests

1 participant