Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix tests

Chocobozzz17e2705f646f
diff --git a/shared/extra-utils/miscs/webtorrent.ts b/shared/extra-utils/miscs/webtorrent.ts
index b610fdda8a..0683f88938 100644
--- a/shared/extra-utils/miscs/webtorrent.ts
+++ b/shared/extra-utils/miscs/webtorrent.ts
@@ -10,8 +10,8 @@ let webtorrent: WebTorrent.Instance
function webtorrentAdd (torrentId: string, refreshWebTorrent = false) {
const WebTorrent = require('webtorrent')
- if (!webtorrent) webtorrent = new WebTorrent()
- if (refreshWebTorrent === true) webtorrent = new WebTorrent()
+ if (webtorrent && refreshWebTorrent) webtorrent.destroy()
+ if (!webtorrent || refreshWebTorrent) webtorrent = new WebTorrent()
webtorrent.on('error', err => console.error('Error in webtorrent', err))