Kucoin / kucoin-node-sdk

KuCoin API SDK for Node.js language.
Apache License 2.0
106 stars 53 forks source link

Catching "Too many request" error #40

Open fedeiglesias opened 1 year ago

fedeiglesias commented 1 year ago

When I make an overload test, calling getOrderById too many times in shot amount of time, i can't catch request limit error.

My intention is to catch this error, wait 10 seconds or more and retry the request. But using a Try-Catch block to make this happen I get always next error:

FetchError: invalid json response body at https://api.kucoin.com/api/v1/orders/62d99d248d3eb700016140dc? reason: Unexpected token < in JSON at position 0

I was digging into the createHttp lib, I think this can be the problem https://github.com/Kucoin/kucoin-node-sdk/blob/8a79c5d5fff46e0aca816e45df8b1dda12f058b2/src/lib/createHttp.js#L92

Can anyone give me some help on this?

ISAAC-XXYYZZ commented 1 month ago

Our backend system has a strict rate-limiting policy. Please refer to it here: https://www.kucoin.com/docs/basic-info/request-rate-limit/rest-api. Currently, rate-limiting information is not passed to the caller (in the headers), but we plan to include this in future iterations