web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

web3.eth.getTransactionReceipt gets unexpected response?

Open kevgithub opened this issue 3 years ago • 2 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Current Behavior

Here is my code:

function listenTransaction(data, contractaddress, hash, fnSuccess, fnFailed){
web3.eth.getTransactionReceipt(hash, function(error, receipt){
    if(!receipt){
         listenTransaction(data, contractaddress, hash, fnSuccess, fnFailed);
    }
     else{
        fnSuccess && fnSuccess(receipt);
     }
    if(error){
         error = typeof error === 'string' ? error : JSON.stringify(error);
        ajaxErrorLog('Error,' + error);
    }
     if(receipt && !receipt.status){
        ajaxErrorLog('Error,' + JSON.stringify(receipt));
    }
})
};

According to the documentation, when a transaction is pending, both ‘error’ and ‘receipt’ should be null. When the transaction is confirmed, the receipt returns a value, but recently I found a transaction in my log file, hash:0xaa0a83f7b0e1d26b4983d433d80466c246d68ccbfa0379537f03d5ea56e6f48f, the error keeps returning {}(not null), and the receipt is always empty. This situation lasts for more than 30 minutes, causing my program to think that the transaction has not been successful, but I checked the transaction on Etherscan, and it actually has been confirmed within 9 seconds,

Expected Behavior

why is this happening?

Steps to Reproduce

why is this happening?

Web3.js Version

1.5

Environment

  • Operating System:
  • Browser:
  • Node.js Version:
  • NPM Version:

Anything Else?

No response

kevgithub avatar Dec 18 '22 16:12 kevgithub

hey @kevgithub, happy new year!

I just tested on 1.8.1 and everything seemed to work fine. Could you please verify?

nikoulai avatar Jan 03 '23 14:01 nikoulai

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Mar 05 '23 00:03 github-actions[bot]