killemov / Shift

A minimalistic approach to maximum control of your Transmission. (Web UI)
https://forum.transmissionbt.com/viewtopic.php?f=8&t=12555
260 stars 20 forks source link

infinite loops after viewing torrents in error condition #21

Closed Fedyon closed 2 years ago

Fedyon commented 2 years ago

... because getErrorData() and updateTorrents() call the other one indefinitly.

killemov commented 2 years ago

Yes, these functions do call each other, but as far as I can determine the following piece of code in updateTorrents() should prevent calling getErrorData() for torrents that have the errorString set. Barring some rare possible race condition of course.

  t.update( torrent );
  if( t.error !== 0 && isEmpty( t.errorString ) ) {
    eids.push( t.id )
  }

Please point out my mistake, if any.

Fedyon commented 2 years ago

Oh yes-ish, you're right! I had those checks disabled locally and forgot about that, sorry...

But, but that piece is preventing almost all errors from notification. In other words, with those checks intact, updateTorrents()->getErrorData() path is actually doing nothing. Even if any went through it, it doesn't make sense: t.errorString is now guaranteed to be Empty, so down the path sendNotification() won't generate any meaningful message. I'm not sure how those supposed to work. I'm confused...

killemov commented 2 years ago

Oh yes-ish, you're right! I had those checks disabled locally and forgot about that, sorry...

So disabling these conditions actually caused the infinity which caused you to file this issue. Why do this?

But, but that piece is preventing almost all errors from notification. In other words, with those checks intact, updateTorrents()->getErrorData() path is actually doing nothing. Even if any went through it, it doesn't make sense: t.errorString is now guaranteed to be Empty, so down the path sendNotification() won't generate any meaningful message. I'm not sure how those supposed to work. I'm confused...

Please do your research before making these claims. So closing until an actual issue needs to be addressed.

Fedyon commented 2 years ago

Sorry for noises and inconveniences I made, I now realized that in normal circumstances, unmodified sendNotification() is actually just a null func for the time being, because Notification.requestPermission( f ) will never succeed (undefined f). So all the trouble was of mine and just moot.

(as to why: I usually have dom.webnotifications.enabled=false set, so I just added console.log to sendNotification() on sight. Then I found it logging Torrent error. "...": (nothing after :) everytime at opening shift. I naively assumed that those null error should not reach to sendNotification(), and thoughtlessly flipped the logic. It looked okay at that time without errored ones, errors don't happen often, and I forgot about that totally. oops...)

Anyway thanks for your work!