Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCas <6506529+ThaUnknown@users.noreply.github.com>2022-06-23 22:03:37 +0300
committerGitHub <noreply@github.com>2022-06-23 22:03:37 +0300
commit2e4f91f668ea867d768291e9efd3e1c1eb825b97 (patch)
treed5cb67dc000d6d2d642448472d3ff56fc293ef4c /index.js
parente74a6219e7b11a870760adffed5377840e0f01cd (diff)
fix: support stream cancelling (#2335)
Diffstat (limited to 'index.js')
-rw-r--r--index.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/index.js b/index.js
index e7b56a8..1476004 100644
--- a/index.js
+++ b/index.js
@@ -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() }