Workers zlib failure when trying to gunzip data
Hi all,
I'm trying to develop a worker that stores and fetches gzipped data in R2. Data is a ~300kb json file but when gzipped is only ~20kb.
I've enabled polyfills (setting
node_compat = true
in wrangler.toml) to be able to use zlib. Compressing the json works fine. However, when trying to uncompress it I'm getting the following
1. "TypeError: Not a string or buffer" when trying to use an ArrrayBuffer
2. "TypeError: Cannot read properties of undefined (reading '-5')" when converting data from R2 object to a Buffer.
Is there any supported way to uncompress a file in a worker?
I believe the issue might be in https://github.com/ionic-team/rollup-plugin-node-polyfills that you're using - but the library seems to be no longer maintained.GitHub
GitHub - ionic-team/rollup-plugin-node-polyfills
Contribute to ionic-team/rollup-plugin-node-polyfills development by creating an account on GitHub.
3 Replies
Example code for 1. above is:
Ends up with:
`
Iād recommend just using DecompressionStream
https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream
Example code for 2. is:
Ends up with:
Thanks for que quick reply, let me try that! š
@kian it works, thank you!!