robbederks / downzip

NPM library to enable client-side code to stream potentially large files into a zipped download
MIT License
35 stars 12 forks source link

Ability to interrupt a download? #44

Open pandaiolo opened 5 months ago

pandaiolo commented 5 months ago

Hey there, first of all, thanks for making this library available 🙏

I have been using it for some time and notice that when a large zip download is started, it seems that it cannot stop?

Is there a way to:

  1. Stop the download automatically under some circumstances (user cancelled download)
  2. Stop the download programmatically (calling a method or sending a message to the worker?)
robbederks commented 5 months ago

If the service worker stays running then I suppose that it would indeed continue to download with the current setup. Shouldn't be too hard to modify that code to add a "stop" trigger that exits the loop after the current chunk. If you do, please submit a PR and I'd be happy to upstream.

pandaiolo commented 5 months ago

Thank you

My 1st point above seems more like a browser bug? - with the underlying stream not being canceled when user interrupts the download. Here are some related Chromium bug reports: