jimmywarting / StreamSaver.js

StreamSaver writes stream to the filesystem directly asynchronous
https://jimmywarting.github.io/StreamSaver.js/example.html
MIT License
3.95k stars 413 forks source link

abort behavior of making zip in the latest FF (greater than v100) #298

Open wangf1978 opened 1 year ago

wangf1978 commented 1 year ago

From Firefox v100, WritableStream is already supported, don't need third-party ponyfill anymore. However, the StreamSaver implementation has different behavior to abort making zip in FF comparing with Chrome/Edge, here is the detailed information: In zip-stream.js

  export default function createWriter (underlyingSource) {
  .....
    return new ReadableStream({
      start: c => {
        ctrl = c
        underlyingSource.start && Promise.resolve(underlyingSource.start(zipWriter))
      },
      pull () {
        return processNextChunk() || (
          underlyingSource.pull &&
          Promise.resolve(underlyingSource.pull(zipWriter))
        )
      }
    })
  }

If underlyingSource.pull receive an exception, and generate a promise reject, in Chrome/Edge, the download will stop, and no zip stream is written to local downloader folder, it is perfect!

But in the FF, the zip file is still created, and saved to the local download folder although in FF download manager it showed "fail"

image image

Any hint to solve this issue? I tried fileStream.abort, writer.abort, all of them can't solve this issue in FF