fallen-icarus / p2p-wallet

A fully p2p Cardano wallet desktop app with full DeFi support, and a transaction builder for building arbitrarily complex transactions.
Apache License 2.0
7 stars 0 forks source link

Pool picker stuck in loop due to insufficient timeout #4

Open TerminadaPool opened 2 days ago

TerminadaPool commented 2 days ago

When trying to change my wallet stake delegation it seems to get stuck in a loop with screen showing "syncing pools...". Eventually after hours of letting it run, I see the following error:

FailureResponse (Request {requestPath = (BaseUrl {baseUrlScheme = Https, baseUrlHost = "api.koios.rest", baseUrlPort = 443, baseUrlPath = "api/v1"},"/pool_info"), requestQueryString = fromList [("select",Just "pool_id_bech32%2Cmargin%2Cfixed_cost%2Cpledge%2Cmeta_json%2Cpool_status%2Cretiring_epoch%2Cactive_stake%2Csigma%2Cblock_count%2Clive_pledge%2Clive_stake%2Clive_delegators%2Clive_saturation"),("sigma",Just "not.is.null"),("meta_json",Just "not.is.null")], requestBody = Just ((),application/json;charset=utf-8), requestAccept = fromList [application/json;charset=utf-8,application/json], requestHeaders = fromList [], requestHttpVersion = HTTP/1.1, requestMethod = "POST"}) (Response {responseStatusCode = Status {statusCode = 429, statusMessage = "Too Many Requests"}, responseHeaders = fromList [("deny-reason","Exceeded Tier Limit, count was 5021"),("content-length","0")], responseHttpVersion = HTTP/1.1, responseBody = ""})

As you suggested over matrix chat, changing the following code timeout line at: https://github.com/fallen-icarus/p2p-wallet/blob/42c83397feba6511cf44babc387bf841cce46de0/app/P2PWallet/Actions/Query/Koios.hs#L107

from:

{ HTTP.managerResponseTimeout = HTTP.responseTimeoutMicro 5_000_000

to:

{ HTTP.managerResponseTimeout = HTTP.responseTimeoutMicro 10_000_000

Appears to fix the issue.

fallen-icarus commented 2 days ago

Since Koios can occasionally take too long to respond, the p2p-wallet just retries if the response times out. However, in this case, it continuously timed out and continuously retried...

In addition to increasing the default timeout, I will add a cap for the maximum number of tries. Queries should never take more than a few minutes so users should never wait hours to find a bug.

fallen-icarus commented 2 days ago

While exploring this bug, I'm now seeing a 504 Gateway Timeout response (after adding the cap to the possible number of retries). This occurs whenever Koios take more than 30 seconds to respond. When looking up the pool info for each registered pool, sometimes Koios would take over a minute to respond while other times it would respond within 5 seconds. The 504 Gateway Timeout is actually fairly common when querying pool info so I think this is why the pool picker kept getting stuck in a loop. This is only an issue for mainnet.

I've opened a bug about it on Koios.