Calling `getPlayersOfFaction` causes 429 HTTP error
ugobriasco opened this issue · 1 comments
ugobriasco commented
Describe the bug
The method getPlayersOfFaction
is constantly causing 429 errors on RPC level
To Reproduce
Reproduced in v0.3.3 and 0.4.4
const { Connection, PublicKey } = require('@solana/web3.js');
const {
getPlayersOfFaction
} = require('@staratlas/factory');
const CONNECTION = new Connection('https://api.mainnet-beta.solana.com');
const FACTION_PROGRAM = new PublicKey(
'FACTNmq2FhA2QNTnGM2aWJH3i7zT3cND5CgvjYTjyVYe'
);
const getPlayersFaction = async (factionId) => {
const players = await getPlayersOfFaction(
CONNECTION,
factionId,
FACTION_PROGRAM
);
return players.map((p) => p.owner);
};
getPlayersFaction(0)
Returns
Server responded with 429 Too Many Requests. Retrying after 500ms delay...
Server responded with 429 Too Many Requests. Retrying after 1000ms delay...
Server responded with 429 Too Many Requests. Retrying after 2000ms delay...
...
Error: 429 Too Many Requests: {"jsonrpc":"2.0","error":{"code": 429, "message":"Too many requests for a specific RPC call, please contact your app developer to further troubleshoot. If you are using an open endpoint, please consider signing up for your own subscription to avoid getting rate limited, you can find some suitable options at https://solana.com/rpc."}
Expected behavior
RPC queries should be throttled to match the Solana RPC specs
Additional context
A bunch of weaks ago this issue was not happening, while now is constant, independently if I use version 0.3.x or 0.4.x
ugobriasco commented
The problem was related to the RPC node used. By using another one, all good