gildas-lormeau/zip.js

Cannot read properties of undefined (reading 'byteLength')

gund opened this issue · 1 comments

gund commented

Hi, I'm trying to use your library to implement client side downloading feature and zipping of files.

It's a bit tricky setup but essentially I have a bunch of files which I'm downloading one by one using fetch API and then passing fetch streams to Webworker which is using TransformStream to zip those files into a single stream, which in the end is handed over to the browser as a file download.
I'm using vite as a bundler for the app.

And when I'm trying to invoke zipping in the worker I'm getting the following error:

TypeError: Cannot read properties of undefined (reading 'byteLength')
    at sendMessage (@fs/workspaces/main/node_modules/.vite/deps/@zip__js_zip__js.js?v=f995fa79:8228:43)
    at onMessage (@fs/workspaces/main/node_modules/.vite/deps/@zip__js_zip__js.js?v=f995fa79:8277:9)

Assuming from the error stack your library is trying to use it's own Webworker which is unnecessary as it's already invoked in dedicated worker, so maybe there is a way to disable it? Or is there another option that I can try?

Thanks in advance!

UPDATE: I removed custom Webworker from the equation and still getting the same error.

gund commented

Ok, I've figured out that the problem was with my custom text files that I was generating on the fly.
I was writing to the stream plain text without encoding it via TextEncoder but once I fixed it the error is gone and it's working properly now!

Thanks again for this awesome and modern library!
Cheers!