Monior pending transaction,cant find my test tx in time

hey guys,im trying to monitor an address ,and do smth when there is a pending transaction send out,and i wrote this as blow, i do get many pending transactions hash,but seems like no one is the one i sent,and i waited couple minutes still didnt get the tx i want and it even get minted,so what should i do or did i missed someth?

web3.eth.subscribe('pendingTransactions',(error, hash)=>{
    web3.eth.getTransaction(hash, (error, transaction) => {
        //success get here
        if(transaction.from == myAddress){
            // should do smth here
            //but it's very slow,i sent tx with metamask,and i got the transaction about 10 seconds later,how to optimize this
        }
    })
})

Hi @mrwentaowinter! Welcome to the Infura community!

It looks like you may have a typo on your second line with “(error, trasaction)” - I’d try changing that to “transaction” and see if that fixes your problem.

haha,thanks,that’s a typo,as i write this on infura forum ,and in my code it is written correctly,the thing is ,i can get pending transaction and can get transaction details,but it’s not on time

Got it. We’re checking into it now and will let you know as soon as we have something!

We’re sorry you’re running into this issue. Unfortunately, once the tx has been mined, we’re not able to go back in time to when it was in a pending state to debug it. We don’t currently track all the pending transactions that are coming into our network but if it got mined, we are definitely getting it and propagating it to the network. Various things like network congestion, how many total pending txs there are and what your gas price is set to can affect how fast a pending tx gets mined and how long that pending transaction takes to propagate to the rest of the nodes in our network, which may explain the behavior you are seeing.

Was this a one-time behavior or are you not seeing any of our pending transactions from the newPendingTx subscription? Could you provide us with more information on what gas prices are set to and what it is you are trying to do with the pending tx data?