dsafa/audio-band

Infinite loop re-opening auth tabs after failure.

TrySpace opened this issue ยท 14 comments

Describe the bug
Suddenly my browser started opening tabs in a loop, trying to authenticate with spotify. It kept doing this until I killed explorer.exe. Then when restarting, it kept doing it, so I disabled spotify as a source and it stopped.
Nothing has nor had changed about my API key, and after a few days I've enabled it again, and it opened up a tab quickly and authenticated, that's it.

To Reproduce
Not sure how to repro, it seems that if the spotify auth service is down, it will get stuck in a loop.

Expected behavior
A limited amount of tries to authenticate. An awareness of the app of recent auth attempts?
At least it should not infinitely retry, or assume spotify api is up 100%.

I was at about 60 new open tabs I think, Imagine what would've happened if I were gone for the day, or just an hour of shopping... 10000 tabs :D

Version Info

  • Windows version 10
  • AudioBand Version 0.9.4

https://github.com/dsafa/audio-band/blob/master/src/SpotifyAudioSource/SpotifyAudioSource.cs#L657
Possibly the fact this is calling Authorize which itself can possibly call RefreshAccessToken again (I think?), not sure, but the loop seems to be in there.

I have now also hit this issue.

Extract from log;

2020-05-13 12:00:20.6921|DEBUG|AudioSource(Spotify)|Getting new access token
2020-05-13 12:00:20.8010|DEBUG|AudioSource(Spotify)|Received new access token. Expires in: 01:00:00 (At 13/05/2020 1:00:20 PM)
2020-05-13 13:00:21.5849|WARN|AudioSource(Spotify)|Error while trying to get playback. Code: 401. Message: The access token expired
2020-05-13 13:00:21.5849|DEBUG|AudioSource(Spotify)|Getting new access token
2020-05-13 13:00:21.6987|DEBUG|AudioSource(Spotify)|Received new access token. Expires in: 01:00:00 (At 13/05/2020 2:00:21 PM)
2020-05-13 14:00:23.0858|WARN|AudioSource(Spotify)|Error while trying to get playback. Code: 401. Message: The access token expired
2020-05-13 14:00:23.0858|DEBUG|AudioSource(Spotify)|Getting new access token
2020-05-13 14:00:23.1879|WARN|AudioSource(Spotify)|Error getting new token. Requesting new refresh token. Error: server_error|
2020-05-13 14:00:23.2109|DEBUG|AudioBand.UI.AudioSourceSettingKeyValue|Starting edit
2020-05-13 14:00:23.2197|DEBUG|AudioBand.UI.AudioSourceSettingsCollectionViewModel|Starting edit
2020-05-13 14:00:23.2417|DEBUG|AudioSource(Spotify)|Connecting to spotify
2020-05-13 14:00:24.1026|WARN|AudioSource(Spotify)|Error while trying to get playback. Code: 401. Message: The access token expired
2020-05-13 14:00:24.1026|DEBUG|AudioSource(Spotify)|Getting new access token
2020-05-13 14:00:24.1597|WARN|AudioSource(Spotify)|Error getting new token. Requesting new refresh token. Error: invalid_request|refresh_token must be supplied
2020-05-13 14:00:24.1597|DEBUG|AudioSource(Spotify)|Connecting to spotify
2020-05-13 14:00:25.4317|WARN|AudioSource(Spotify)|Error while trying to get playback. Code: 401. Message: The access token expired
2020-05-13 14:00:25.4317|DEBUG|AudioSource(Spotify)|Getting new access token
2020-05-13 14:00:25.5079|WARN|AudioSource(Spotify)|Error getting new token. Requesting new refresh token. Error: invalid_request|refresh_token must be supplied
2020-05-13 14:00:25.5079|DEBUG|AudioSource(Spotify)|Connecting to spotify
2020-05-13 14:00:26.9776|WARN|AudioSource(Spotify)|Error while trying to get playback. Code: 401. Message: The access token expired

This caused around 200 tabs to open while troubleshooting the potential cause. For someone with only one monitor this could be near impossible to troubleshoot as the opening of the new tab brings the internet browser to the foreground.

This check appeared to have no minimal retry timer.

Same setup and issue here. If I wasn't connected to an external monitor, it would have been absolutely impossible to deal with.

Had to kill explorer.exe to get things back.

To resolve, I manually restored a single tab from firefox, logged into spotify, and then restarted the audioband toolbar. It immediately opened up a new auth tab but automatically logged in and didn't open new ones.

Same here, it appears from time to time.
Yesterday I was not in front of my computer, it opens 2000+ tabs on my browser... I disabled AudioBand on my two computers since.
It seems to be not maintained anymore...

Wow this is really a brutal one, good thing I scrolled through the issues here while i was first installing it, i would've never survived this browser tab 'attack' without this thread. Going to look for another little program that does the same thing cause this is way too unpredictable.

@sibebleuze what about https://github.com/evilpro/Taskplay?

I was looking for something simple like this. Thanks @sibebleuze.

@AlexByte it's simple, but maybe a little too simple, because those three buttons are built in to my keyboard already, thanks for the suggestion anyway, if you know something that displays song title and maybe even progress through the song, then let me know cause that's what i'm looking for

what about making the taskbar transparent through the classic shell and putting the player behind?

I just had this issue randomly last night. I couldn't get the tabs to stop opening and had to restart my computer. Now it's not connecting to Spotify. I've tried resetting everything and it's just not working -- I must be missing something.. Which sucks because I really love having the mini player to see the song titles without having to open the spotify window back up..

I just had this issue randomly last night. I couldn't get the tabs to stop opening and had to restart my computer. Now it's not connecting to Spotify. I've tried resetting everything and it's just not working -- I must be missing something.. Which sucks because I really love having the mini player to see the song titles without having to open the spotify window back up..

Can you post your logs? To help pinpoint your issue.

Ok, i have been able to reproduce this issue.
This seems to happen when the refresh token becomes invalid. Either because it has expired or the user has revoked access.
The issue happens because the flows for authorization and refreshing is the same when they should really be separate.
More information on Spotifys page for developers if you are interested here: https://developer.spotify.com/documentation/general/guides/authorization-guide/

If i get time i will see if i can separate the flows, but i cant promise anything. I have implemented a safeguard for myself that limits the authorization requests to 5 for now, to make it easier to debug and work with. it's really crude for now and still fills the logfile until you disable Spotify as a Source, the true fix would be to separate the flows as mentioned above.

@kodbulten Do you have a code snippet for it, or a PR so we can see? So I can implement it for myself in the meantime.

It's probably around here? https://github.com/dsafa/audio-band/blob/master/src/SpotifyAudioSource/SpotifyAudioSource.cs#L657

This should fix the issue and add some nice retries to boot :)