Building an efficient zipfile explorer on Cloudflare #546
-
I tried this in a cloudflare worker to stream all files of a zip into r2, but can't get it to respond, it keeps hanging at the end See reproducible repo: https://github.com/CodeFromAnywhere/cloudflare-zip I've tried many things to make the hang go away but didn't succeed. Just leaving it here because maybe anyone has encountered this problem before? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
I tested your code but I was not able to reproduce the issue. Here is what I did. Run the following commands in the terminal:
Comment this part https://github.com/CodeFromAnywhere/cloudflare-zip/blob/21ba4e08fece4dbd764fae2fec77a2c8d9db6cf5/main.ts#L42-L58. Press On my machine, the message |
Beta Was this translation helpful? Give feedback.
-
Maybe this depends on the size of the zip. Try http://localhost:8787/?url=https://github.com/oven-sh/bun/archive/refs/heads/main.zip that one got stuck for me for sure, the facebook/react sometimes only gave errors. I think it depending on the worker limits could be strange because it keeps hanging at the end, it doesn't give any error. However maybe putting this into a deployment would shed more light on it. I don't have time to get back into it now though, it's not my priority. I think it'd be very useful though to use a serverless environment to unpack and store particular files from zips. |
Beta Was this translation helpful? Give feedback.
-
Could be the memory indeed, and I know 128 mb is quite the restriction, but how would it run out of memory? I'm using |
Beta Was this translation helpful? Give feedback.
-
Thanks for that! I changed the topic of this discussion and would like to share my plan of building a efficient zip file explorer on cloudflare: https://github.com/CodeFromAnywhere/cloudflare-zip Do you think this seems feasible? I will give this a go soon Basically what I'm trying to do is use the range header so we can only get the central directory first, then create a filter on that and do a follow up range request so we only get the files we want. Would this be possible with zip.js? Is it true (what Claude suggests) that zip.js only does a range request when you do I am planning on trying to build this out soon |
Beta Was this translation helpful? Give feedback.
-
Normally, if you want to use requests with the Range header, you only need to use |
Beta Was this translation helpful? Give feedback.
I don't know what could cause this issue but I can reproduce it with the code below and the last example of URL you mentioned. As you can see, it does not depend on zip.js at all. Maybe you should contact the support at Cloudflare because it looks like it's a bug.