chr15m / bugout

Back end web app services over WebRTC.
https://chr15m.github.io/bugout
MIT License
612 stars 59 forks source link

Prevent app crash on destroy() #72

Open Kos-M opened 4 months ago

Kos-M commented 4 months ago
/app/sa/node_modules/webtorrent/index.js:424
    if (!torrent) throw new Error(`No torrent with id ${torrentId}`)
                  ^

Error: No torrent with id [object Object]
    at WebTorrent.remove (/app/sa/node_modules/webtorrent/index.js:424:25)
    at WebTorrent.remove (/app/sa/node_modules/webtorrent/index.js:420:49)
    at Bugout.destroy (/app/sa/node_modules/bugout/index.js:159:13)
    at Connector.healthCheckRealaytorConnection (/app/sa/src/connector.js:200:17)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

Seems webtorrent thows an error when we call remove() with a wrong id. (for reference Line 407

We need to prevent it , maybe we can include this line inside a try catch : https://github.com/chr15m/bugout/blob/62ddbc85365fc508eddcb8d5ab3a35b3ed000712/index.js#L159

I faced above error , in a reconection mechanism i have implemented in my app , so im calling bugout destroy() in an interval.. It works as expected , except this crash..

chr15m commented 4 months ago

Sounds good, send a PR if you want. I can merge it but I don't want to push anything to npm without basic browser testing and I don't really have time to do this myself.