Open epsil opened 7 years ago
JMPerez, one of spotify-web-api-node's project owners, replied:
One option would be to have this built in, but we tried to keep the library as light as possible. What I have recommended in the past is to use something like https://github.com/JMPerez/promise-throttle. You can see an example of the library used together with the client-side Spotify JS wrapper on https://github.com/JMPerez/spotify-dedup/blob/b6091581e3700ccbb1e5a0e26dbb59422fa3d15f/app/scripts/main.js#L80.
This project should use an external library for Spotify requests. Since it is rather request-intensive, throttling is an absolute must so that we don't butt up against Spotify's rate limits.
Currently, Spotify requests are handled by our own
spotify.js
layer, which depends on thehttp.js
client to enforce limits. In practice, this is done with asetTimeout()
call with a delay set to 100 ms.The most promising replacement library seems to be spotify-web-api-node. Unfortunately, that library currently lacks options for HTTP throttling. Until this issue is resolved, we will, of necessity, stick with our own implementation for the time being.