diff options
author | Cas <6506529+ThaUnknown@users.noreply.github.com> | 2022-06-23 22:03:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-23 22:03:37 +0300 |
commit | 2e4f91f668ea867d768291e9efd3e1c1eb825b97 (patch) | |
tree | d5cb67dc000d6d2d642448472d3ff56fc293ef4c /index.js | |
parent | e74a6219e7b11a870760adffed5377840e0f01cd (diff) |
fix: support stream cancelling (#2335)
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -222,7 +222,11 @@ class WebTorrent extends EventEmitter { this.workerPortCount++ port.postMessage(response) }) - cb(this.serviceWorker) + // test if browser supports cancelling sw Readable Streams + fetch(`${this.serviceWorker.scriptURL.slice(0, this.serviceWorker.scriptURL.lastIndexOf('/') + 1).slice(window.location.origin.length)}webtorrent/cancel/`).then(res => { + res.body.cancel() + }) + cb(null, this.serviceWorker) } get downloadSpeed () { return this._downloadSpeed() } |