Skip to content

Commit

Permalink
Replicated chrome (canary: 99.0.4828.0) user cancellation behaviour o…
Browse files Browse the repository at this point in the history
…n Firefox

Cleanup unused reference
  • Loading branch information
gwdp committed Jan 14, 2022
1 parent cd8e32a commit f9e375e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions StreamSaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@
// We never remove this iframes b/c it can interrupt saving
makeIframe(evt.data.download)
}
} else if (evt.data.abort) {
chunks = []
channel.port1.postMessage('abort') //send back so controller is aborted
channel.port1.onmessage = null
channel.port1.close()
channel.port2.close()
channel = null
}
}

Expand Down
5 changes: 3 additions & 2 deletions sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ function createStream (port) {
controller.enqueue(data)
}
},
cancel () {
console.log('user aborted')
cancel (reason) {
console.log('user aborted', reason)
port.postMessage({ abort: true })
}
})
}
Expand Down

0 comments on commit f9e375e

Please sign in to comment.