Announcements

Help Wizard

Step 1

NEXT STEP

Timeout on Successful POST to Queue endpoint

Solved!

Timeout on Successful POST to Queue endpoint

Hello,

I have had a functioning web app for over a year now that lets users post songs to their queue from browser. With no changes from my end in this period, the app is now suddenly returning a timeout error of 1000ms exceeded from the add to queue endpoint. Weirdly, the request is still successful, as in, the song still gets posted to the queue, but the error in the response is causing my app to fall into the catch block and incorrectly say the song was not added, when it was.
Reply

Accepted Solutions
Marked as solution

I've done rigorous analysis on this and the only conclusion I can come to is this is your API behaving badly with its responses. The POST to the queue is successful but the API is returning a timeout error. The result of this is that my code cannot enter the .then block after POSTing. It only hits the catch block despite the POST succeeding.

 

I removed the timeout 1000ms restriction in my axios instance and it solved this. 

View solution in original post

2 Replies

Code:

 

(songURI, songInfo) => {
return instance.post(C.addSongURI, {}, {
params: { 'uri': songURI }
})
.then(response => {
return songInfo + C.addSuccess
})
.catch(error => {
return songInfo + C.addError
})

 

Error: 

 

{
"message": "timeout of 1000ms exceeded",
"name": "Error",
"stack": "Error: timeout of 1000ms exceeded\n at createError (/var/task/node_modules/axios/lib/core/createError.js:16:15)\n at RedirectableRequest.handleRequestTimeout (/var/task/node_modules/axios/lib/adapters/http.js:280:16)\n at RedirectableRequest.emit (events.js:400:28)\n at Timeout._onTimeout (/var/task/node_modules/follow-redirects/index.js:166:12)\n at listOnTimeout (internal/timers.js:557:17)\n at processTimers (internal/timers.js:500:7)",
"config": {
"url": "/me/player/queue",
"method": "post",
"data": "{}",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json;charset=utf-8",
"Authorization": "Bearer BQB1YlzxkeboPNLWtGHTBVDUXFsktuLzOhvJ7MKWt_BTNcIeX-sfTvSSbKFdkB-GM824ZmgCzcDZtkelERqiJ3x6m0QkriWI-Vt-8rjIFo_DfxI9vvOU2dTgNY2bQexe8geFbzT1rYWdfwFwVLnaoHXliFbMQnH64LzQ65wQbxAHCQad",
"User-Agent": "axios/0.21.1",
"Content-Length": 2
},
"params": {
"uri": "spotify:track:0U1W2LZVUX7qTm7dDpqxh6"
},
"baseURL": "https://api.spotify.com/v1",
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 1000,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"maxBodyLength": -1
},
"code": "ECONNABORTED"
}

 

 

Marked as solution

I've done rigorous analysis on this and the only conclusion I can come to is this is your API behaving badly with its responses. The POST to the queue is successful but the API is returning a timeout error. The result of this is that my code cannot enter the .then block after POSTing. It only hits the catch block despite the POST succeeding.

 

I removed the timeout 1000ms restriction in my axios instance and it solved this. 

Suggested posts

Let's introduce ourselves!

Hey there you, ย  Yeah, you!ย 😁 ย  Welcome - we're glad you joined the Spotify Community! ย  While you here, let's have a fun game and getโ€ฆ

ModeratorStaff / Moderator/ 4 years ago  in Social & Random