Error Message: Query Timout Exceeded

Hello,

I am getting an error message when I use the Infura API. The error I receive says "Returned error: query timeout exceeded’. I did not receive any further information.

I am querying a large amount of information and I am relatively new to programming. What is the best way to respect the request limiter?

Hi Julian,

Can you let us know what is the api call that timeouts and how you do it (the relevant piece of code would help) ?

Thanks,
Traian

Hi Traian,

The relevant piece of code is below. It is a “deep forloop”. The method I call is getPastEvents on at least 6 different contracts.

Let me know if you would like me to provide any information.

let collect_filter_and_sort_events = async() => {
    try {
        let total_events = [];
        let liquidityGates = [CompoundLiquidityGateAddresses, AaveLiquidityGateAddresses, dYdXLiquidityGateAddresses, FulcrumLiquidityGateAddresses]
        let agg_protocol_sender_address_collection = [yearn_liquidity_transfer_addresses, IdleFinance_sender_addresses]
        let underlying_asset_info = [DAI, USDT, BUSD, SUSD, TUSD, WBTC];

        for (agg_protocol of agg_protocol_sender_address_collection) {

            for (underlying_asset of underlying_asset_info) {

                if (underlying_asset.name in agg_protocol) {
                    // DAI is in Yearn, so it returns true                        
                    for (agg_port_address of agg_protocol[underlying_asset.name].addresses) {

                        for (liquidityGate of liquidityGates) {

                            if (underlying_asset.name in liquidityGate) {

                                for(liquidity_gate_address of liquidityGate[underlying_asset.name]) {
                                    for (contract of underlying_asset.addresses) {
                                        
                                        let depositing_events = await contract.interface.getPastEvents('Transfer', 
                                            {
                                                filter: {
                                                    src: agg_port_address, 
                                                    dst: liquidity_gate_address
                                                }, 
                                                fromBlock: yearn_liquidity_transfer_addresses.starter_block, 
                                                toBlock:'latest' 
                                            }
                                        )
                                        let withdraw_events = await contract.interface.getPastEvents('Transfer',
                                            {
                                                filter: {
                                                    src: liquidity_gate_address, 
                                                    dst: agg_port_address
                                                },                                                    
                                                fromBlock: yearn_liquidity_transfer_addresses.starter_block, 
                                                toBlock: 'latest' 
                                            }
                                        )
                                    }
                                } 
                            }                
                        }
                    }
                }
            }
        }

        total_events.sort(function(a,b) {return a.timestamp - b.timestamp});
        return total_events

    } 
    catch(error) {
        console.log(error)
    };
}

I figured out what I was doing wrong. I was using a debugger, and when I waited too long between getPastEvent calls, the API would time out. Thanks for the help!

Thanks for the updates Julian, I’m glad you’ve figured it out !