Repository navigation
Do not read Spotify's answers to player commands as JSON - #24
Merged
Merged
Conversation
Spotify answers some player commands with a plain-text id ("p2JKrMekJa…")
instead of an empty body. api() parsed every non-empty answer as JSON,
so a play that went through still failed: the window showed "play:
Unexpected token 'p' … is not valid JSON", and the error ended send()
early, so the repeat and shuffle that follow a play could go unsent.
Every api() call is a command whose answer nobody reads, so it no longer
reads one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Playing a song shows "play: Unexpected token 'p', "p2JKrMekJa"... is not valid JSON" in the corner, although the song plays.
Spotify answers some player commands with a plain-text id instead of an empty body, and
api()in player.html parsed every non-empty answer as JSON. The play went through, but the error endedsend()early, so the repeat and shuffle that follow a play could go unsent.No caller of
api()reads its answer (all are PUT commands), so it no longer reads one. A test plays against a plain-text answer and checks that play, repeat and shuffle all go out.Checked:
node --test …/spotify/web/player.test.mjs(the new test fails without the change),cargo test, and plays on my account indev/run gui: the error is gone.🤖 Generated with Claude Code