Yooooomi / your_spotify

Self hosted Spotify tracking dashboard
GNU General Public License v3.0
2.77k stars 110 forks source link

Exit on unrecoverable errors in `dbLoop` #297

Closed invakid404 closed 9 months ago

invakid404 commented 10 months ago

This PR addresses issue #275, which had been closed without a definitive resolution. The solution proposed by this pull request is a straightforward one, without any complicated retry mechanisms. As elaborated in the commit description, this patch ensures that unrecoverable errors thrown within dbLoop() do not get "swallowed" by the catch() in src/bin/www.ts. Consequently, it prevents the server from entering an idle state where it continues to run without importing any recently played songs, a scenario that will result in unexpected data loss.

I remain committed to seeing this issue through to resolution. Although my previous comments in the issue may have come across as emotionally charged, they were not intended to be disrespectful. My sincere intention is to contribute positively to this project. Thank you for your understanding, it's all love.

invakid404 commented 10 months ago

If you find the proposed solution to not be suitable, I also have an alternative approach in mind. This involves wrapping the dbLoop loop body in a try-catch block. By doing so, any potential errors will be handled in the function itself, preventing premature termination of the loop. Initially, I contemplated submitting two separate pull requests, each featuring one of these options, in order to save ourselves a bit of time in back-and-forth communication. However, I ultimately opted against this to avoid causing unnecessary noise.

Please feel free to express your preference, and I will be more than willing to adjust this pull request accordingly. Your feedback is greatly appreciated.

Yooooomi commented 9 months ago

Thanks, I feel like this is enough. We don't need to deep dive into how to handle this. Since it will means either Spotify or mongo is unaccessible thus being in an inrecoverable state. I will maybe add some tweaks to this to identify if this is a temporary issue or fatal (temporary internet issue vs mongo connection issue)