I’m crawling an API. There is many many many requests. And if I do too much requests, the API starts by looking suspicious, and I get a bunch of 503. That’s ok, when I get a 503 I’ve set a timer before re-running the request, and this timer is powered by two for each 503 of a same request.
BUT it doesn’t work. Because my timer is asynchroneous. When I get the 503, after starting this timer, Node immediately reuse the socket for a pending request. So my timer basically doesn’t change anything.
How can I prevent this ?
What I have tried so far :
- using a
settimeoutbefore restarting the request - using the
syncmodule, and itspause(does not work, because the fiber is asynchroneous
Any idea ? :<
I’ve finally come to the conclusion that it is not possible at this time.
In order to prevent massive flooding, I’m using the
queueobject of theasyncmodule. The code is something like that :