Tiago
Tiago
CDCloudflare Developers
Created by Tiago on 11/17/2023 in #workers-help
Workers zlib failure when trying to gunzip data
@kian it works, thank you!!
7 replies
CDCloudflare Developers
Created by Tiago on 11/17/2023 in #workers-help
Workers zlib failure when trying to gunzip data
Thanks for que quick reply, let me try that! 🙂
7 replies
CDCloudflare Developers
Created by Tiago on 11/17/2023 in #workers-help
Workers zlib failure when trying to gunzip data
Example code for 2. is:
const object = await env.BUCKET.get(key);
const blob = await object.blob();
const tmp_array = new Uint8Array(await blob.arrayBuffer());
const data = zlib.gunzipSync(Buffer.from(tmp_array));
const object = await env.BUCKET.get(key);
const blob = await object.blob();
const tmp_array = new Uint8Array(await blob.arrayBuffer());
const data = zlib.gunzipSync(Buffer.from(tmp_array));
Ends up with:
✘ [ERROR] Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '-5')

at Zlib2._binding.onerror
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:356:19)
at status
(file:///[REDACTED]/node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/binding.js:263:6)
at Zlib._write
(file:///[REDACTED]/node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/binding.js:221:7)
at Zlib.writeSync
(file:///[REDACTED]/node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/binding.js:170:8)
at Zlib2._processChunk
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:509:8)
at zlibBufferSync
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:227:7)
at gunzipSync
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:172:8)
at fetch
(file:///[REDACTED]/src/index.js:66:28)
✘ [ERROR] Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '-5')

at Zlib2._binding.onerror
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:356:19)
at status
(file:///[REDACTED]/node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/binding.js:263:6)
at Zlib._write
(file:///[REDACTED]/node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/binding.js:221:7)
at Zlib.writeSync
(file:///[REDACTED]/node_modules/rollup-plugin-node-polyfills/polyfills/zlib-lib/binding.js:170:8)
at Zlib2._processChunk
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:509:8)
at zlibBufferSync
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:227:7)
at gunzipSync
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:172:8)
at fetch
(file:///[REDACTED]/src/index.js:66:28)
7 replies
CDCloudflare Developers
Created by Tiago on 11/17/2023 in #workers-help
Workers zlib failure when trying to gunzip data
Example code for 1. above is:
const zlib = require('zlib');
...
const object = await env.BUCKET.get(key);
const buffer = await object.arrayBuffer();
const data = zlib.gunzipSync(buffer);
const zlib = require('zlib');
...
const object = await env.BUCKET.get(key);
const buffer = await object.arrayBuffer();
const data = zlib.gunzipSync(buffer);
Ends up with:
✘ [ERROR] Uncaught (in promise) TypeError: Not a string or buffer

at zlibBufferSync
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:224:8)
at gunzipSync
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:172:8)
at fetch
(file:///[REDACTED]/src/index.js:66:28)
✘ [ERROR] Uncaught (in promise) TypeError: Not a string or buffer

at zlibBufferSync
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:224:8)
at gunzipSync
(file:///[REDACTED]/.wrangler/tmp/dev-YsNPmS/node-modules-polyfills:zlib:172:8)
at fetch
(file:///[REDACTED]/src/index.js:66:28)
`
7 replies