spotify-player
spotify-player copied to clipboard
Multiple loopInterval can run concurrently
loopInterval can run multiple times concurrently in case the page calls login() more than once.
This can happen if the Spotify user is not playing any song for example, as the library will receive an empty response from Spotify's API, and execute the logout() method, bringing the login button back in view.
The next time the page calls login(), the library will register a second event listener to the 'message' event, and 2 loops will start. One will never be cleared.
Repeat to get as many loops as you can.
A potential fix would be to set the once option to true for this event listener.
https://github.com/JMPerez/spotify-player/blob/ef57833cb07bff148f612e2cedef99b8ae55a8ff/public/spotify-player.js#L99-L117