workbenchapp / solana-workbench

Your one-stop shop for developing on Solana
MIT License
63 stars 7 forks source link

when we do get 429's by an rpc endpoint, we then retry the connection too quickly #263

Closed SvenDowideit closed 2 years ago

SvenDowideit commented 2 years ago

talking to mainnet

related to testing #261

[0]     at async Object.queryTokenMetadata [as queryFn] (http://localhost:1212/data/accounts/getAccount.ts:109:18)
[0] 13:42:06.234 > metadata load Error: failed to get info about account 5x38Kp4hvdomTCnCrAny4UtMUt5rQBdB6px2K1Ui45Wq: Error: 429 :  {"jsonrpc":"2.0","error":{"code": 429, "message":"Too many requests from your IP, contact your app developer or support@rpcpool.com."}, "id": "855f6e00-15eb-420e-b8a1-aac708bf31e5" }
[0]
[0]     at async Object.queryTokenMetadata [as queryFn] (http://localhost:1212/data/accounts/getAccount.ts:109:18)
[0] 13:42:06.235 > metadata load Error: failed to get info about account GChYoEw4qPVRAmPVMTk2J44V67nUSqFF3VxuAtGDNrh6: Error: 429 :  {"jsonrpc":"2.0","error":{"code": 429, "message":"Too many requests from your IP, contact your app developer or support@rpcpool.com."}, "id": "d71dac95-5ff3-4e10-b2f1-70850ffac9d1" }
[0]
[0]     at async Object.queryTokenMetadata [as queryFn] (http://localhost:1212/data/accounts/getAccount.ts:109:18)
[0] 13:42:06.236 > metadata load Error: failed to get info about account HM4kH8kYiun96vEpxDkd2p6cDDjYz3fnkSwKQXmrPAYC: Error: 429 :  {"jsonrpc":"2.0","error":{"code": 429, "message":"Too many requests from your IP, contact your app developer or support@rpcpool.com."}, "id": "801e8d73-4b6c-425f-b765-b306196009cc" }
[0]
[0]     at async Object.queryTokenMetadata [as queryFn] (http://localhost:1212/data/accounts/getAccount.ts:109:18)
[0] 13:42:06.237 > metadata load Error: failed to get info about account 8c3zk1t1qt3RU43ckuvPkCS7HLbjJqq3J3Me8ov4aHrp: Error: 429 :  {"jsonrpc":"2.0","error":{"code": 429, "message":"Too many requests from your IP, contact your app developer or support@rpcpool.com."}, "id": "65409dc7-be03-44e0-836b-4fc0b6e6d943" }
[0]
[0]     at async Object.queryTokenMetadata [as queryFn] (http://localhost:1212/data/accounts/getAccount.ts:109:18)
[0] 13:42:06.244 > metadata load Error: failed to get info about account 6FkAo4nPwbpwyEZEdeLPLTnyGSoWYESZvD1WzJq3Z4wf: Error: 429 :  {"jsonrpc":"2.0","error":{"code": 429, "message":"Too many requests from your IP, contact your app developer or support@rpcpool.com."}, "id": "a2c9190e-fcac-4dc0-8f9c-044aa0f61348" }
[0]
[0]     at async Object.queryTokenMetadata [as queryFn] (http://localhost:1212/data/accounts/getAccount.ts:109:18)
[0] 13:42:06.263 > metadata load Error: failed to get info about account 6kAVgwek7aXiVecsHJEDCFwC8ok9vYm1yc9ETYr8yT82: Error: 429 :  {"jsonrpc":"2.0","error":{"code": 429, "message":"Too many requests from your IP, contact your app developer or support@rpcpool.com."}, "id": "4722c227-5f9c-418e-aaa8-6b501fcffaef" }
SvenDowideit commented 2 years ago

so we can over-ride the fetch() used by the new sol.Connection, but its defined in terms of node-fetch - so causes all sorts of build pain to do with node vs browser-side.

ideally, we'd have a fetch that knows how many requests we've made in the current ratelimit, and queues them up to avoid the thundering herd of complex multi-account display.

SvenDowideit commented 2 years ago

OMFG. so, now that i'm sharing the connection, i'm more likely to DOS theworkbench UI than get ratelimited.

I just picked an account on mainnet who'd response to getParsedTokenAccountsByOwner() retuens 19MB of data

see https://explorer.solana.com/address/6ZRCB7AAqGre6c72PRz3MHLC73VMYvJ8bi9KHf1HFpNk/tokens

TODO: see if we can get paging added to the solana API

the UI freezes, presumably because its busy parsing that data.

access-control-allow-methods: OPTIONS, POST
access-control-allow-origin: http://localhost:1212
access-control-max-age: 86400
content-encoding: gzip
content-type: application/json; charset=utf-8
date: Wed, 20 Jul 2022 03:31:56 GMT
vary: origin
vary: Accept-Encoding
x-ratelimit-conn-limit: 40
x-ratelimit-conn-remaining: 37
x-ratelimit-connrate-limit: 40
x-ratelimit-connrate-remaining: 37
x-ratelimit-method-limit: 10
x-ratelimit-method-remaining: 9
x-ratelimit-rps-limit: 100
x-ratelimit-rps-remaining: 91

is also cool, shame its going to be complex to make use of it.