wnz99 / tvcd

A JS module to fetch realtime candles data from various crypto exchanges. Created to feed TradingView chart.
11 stars 6 forks source link

Invalid request to Bitfinex will timeout if request is invalid? #50

Open hems opened 1 year ago

hems commented 1 year ago

When trying to request the last candle to bitfinex i ended up doing the following request:

https://api-pub.bitfinex.com/v2/candles/trade:1D:tBTCUSD/hist?limit=5000&start=1671062400000&end=1671062400000

I can see bitfinex answers very quick in the browser with:

[
  "error",
  10020,
  "time_interval: invalid"
]

But on my jest test it was timing out because it was taking more than 5000 ms to resolve the request.

I wonder if tvcd will keep retrying to request and for that reason the timeout happens?

wnz99 commented 1 year ago

Can you please try to increase jest timeout?

There's a retry mechanism here: https://github.com/wnz99/tvcd/blob/403f4fc5a74d8c0a28a60399de0278a81e82a25a/src/observables/fetchCandles.ts#L36

I will retry twice with a 5000 ms delay.

We can decrease it if you think it makes sense.

hems commented 1 year ago

it's not supposed to retry when bitfinex API rerturns [ "error" ], that's the point of this issue, it's retrying forever when it should simply abort as the request is invalid!