chr15m / bugout

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

Unexpected crash of app using bugout #70

Open Kos-M opened 5 months ago

Kos-M commented 5 months ago

Hey , i have noticed this weird exception that crashes my app using bugout.

This happens on scenarios that network connectivity is under restoring its state back to online , for example after a laptop hibernation.

https://github.com/chr15m/bugout/blob/62ddbc85365fc508eddcb8d5ab3a35b3ed000712/index.js#L112

/home/t13/Documents/proj/app/node_modules/bugout/index.js:112
  if (this.torrent.discovery.tracker) {
                             ^

TypeError: Cannot read properties of null (reading 'tracker')
    at Bugout._onTorrent (/home/t13/Documents/proj/app/node_modules/bugout/index.js:112:30)
    at /home/t13/Documents/proj/app/node_modules/bugout/index.js:96:14
    at /home/t13/Documents/proj/app/node_modules/bugout/index.js:505:15
    at _onseed (/home/t13/Documents/proj/app/node_modules/webtorrent/index.js:364:41)
    at /home/t13/Documents/proj/app/node_modules/webtorrent/index.js:358:9
    at end (/home/t13/Documents/proj/app/node_modules/run-parallel/index.js:21:15)
    at done (/home/t13/Documents/proj/app/node_modules/run-parallel/index.js:25:10)
    at each (/home/t13/Documents/proj/app/node_modules/run-parallel/index.js:31:7)
    at Torrent.<anonymous> (/home/t13/Documents/proj/app/node_modules/run-parallel/index.js:46:37)
    at Object.onceWrapper (node:events:628:28)

Node.js v20.5.0
error Command failed with exit code 1.

Solution to that could be as easy as that :

 if (this?.torrent?.discovery?.tracker) { 

Let me know your thoughts on this..

chr15m commented 5 months ago

Seems like that would probably fix it!