tomer8007 / spotify-web-ads-remover

Simple extension to remove audio ads on Spotify web player
GNU General Public License v3.0
207 stars 21 forks source link

Stops playing after failure to update state, happens randomly #17

Closed Alvin-He closed 3 months ago

Alvin-He commented 7 months ago

After listening to a playlist for a good while, the track will randomly get stuck after a song finishes. Ref 1 Pressing the next button does not work, the only way to proceed is to manually press play on the next song, but instead of the playing that song, it plays the ad (while showing the song name & icon, time is shown as the ad's). Ref 2 The player then works normally with out any errors until this happens again.

I looked through the console logs and net work logs and it seems to have to do with some access token expiring resulting in a 401 when updating the state. I won't try to explain everything in words, the console log and network HAR file are at the bottom.

I been having this issue for multiple months now, initially I thought it was due to a spotify update that broke something and waited for a patch, but apparently this haven't been reported. It might also be the cause of issue https://github.com/tomer8007/spotify-web-ads-remover/issues/14

Console Log file, initial error (I think that's the initial error) starting on line 156:
open.spotify.com-1705908195262.log

Console Network Har log file (the network request corresponding to the initial error is the request named state that 401ed): open.spotify.com.har

Browser: Opera GX LVL5 (core: 106.0.4998.49) -- It's chromium so I doubt it's the browser's fault
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 OPR/106.0.0.0 OS: Windows 10

Reference image 1: spoti_ads_issue_ref_1 Reference image 2: spoti_ads_issue_ref2

Alvin-He commented 7 months ago

just a note: had it happen again after I manually skipped the song, but this time it doesn't show any errors or show any 401ed state requests

Edit: seems like the state requests fail randomly when this bug happens, after 2 more cycles, it's erroring again

tomer8007 commented 7 months ago

Thanks for the report. I will try to look into this.

tomer8007 commented 7 months ago

seems like the state requests fail randomly when this bug happens,

Are they failing because of 401 Errors, e.g access token refreshing fails?

Alvin-He commented 7 months ago

Actually it seems to be that if the request to https://<spclient some subdomain>.spotify.com/track-playback/v1/devices/<device-id>/state fails, the bug happens

Cause right now I'm not getting these 401 errors anymore, instead it's a different spclient server that's returning 502 and 504s

Screenshot 2024-02-06 200006

image

Edit: There are more 504s, but they are just a shortened error message that says upstream timeout from the 502 url.

Alvin-He commented 7 months ago

actually, I'm still getting same 401s from a url similar to the one that I just mentioned and the bug happened immediately after that. So it's probably related that specific request failing.

Alvin-He commented 7 months ago

oh and em, this happened? image

tomer8007 commented 6 months ago

I see we have an internal timeout grpc error inside Spotify servers, and I'm not sure what's causing it exactly. Does the retry mechanism I added there seem to make the next state request return 200? Do you think adding more retries / more access token refreshes will fix it?

Alvin-He commented 6 months ago

Does the retry mechanism I added there seem to make the next state request return 200?

I didn’t proceed with the debugger so actually don’t exactly know how it affects the next state request😅

the network logs seems to show that the next state request is Ok so the retry mechanism is probably doing it’s job

Adding more retries might help. Have you been able to replicate this?

tomer8007 commented 6 months ago

Have you been able to replicate this?

Not that I'm sure about that. As you saw in the comments I did encounter a 502 in the past, but since this bug is pretty random it's hard for me to reproduce it. I can try to skip a lot of songs or listen a lot but I don't know if this is the way to trigger this.

Alvin-He commented 6 months ago

For me it's just playing a playlist for around 20-30 mins and then the bug would happen. I think happens when you listen a lot.

I'll see if I can add code to do more refreshes this weekend and see if that helps.

Sorry for the late response

Also, idk if this is related, but I'm now Sometimes also getting these errors after the bug happens image

tomer8007 commented 6 months ago

@Alvin-He I also encountered the "could not find the next ad-free state" errors recently, I think it's because Spotify changed some stuff in the states of ads. Seems to be fixed after I commited b5e1a6932c1e2dff9fe3d913316ebaf6fa4e9110.

tomer8007 commented 3 months ago

@Alvin-He I'm closing this for now, if the problem persists you can re-open.