question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type for getTransaction misses `| null`

See original GitHub issue

Ok, so first of all, I found this due to a programming error so probably not an issue that happens for a lot of people, but types could have caught this.

  • provider.getTransaction returns Promise<TransactionResponse>
  • but call this function with a transaction has from e.g. a different chain or a dropped transaction, JSON RPC returns null
  • Ethers (v5) passes along this null while the types think it is a TransactionResponse and do not complain about accessing tx.data for example

Example call in JSON RPC which triggers this in ethers:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xa52be92809541220ee0aaaede6047d9a6c5d0cd96a517c854d944ee70a0ebb44"],"id":53}' -H "Content-Type: application/json" https://mintnet.settlemint.com

{"jsonrpc":"2.0","result":null,"id":53}

Maybe this is client/version specific so for reference this is a Parity Aura network running 2.5.5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
phireskycommented, Sep 14, 2020

Unfortunately adding | null will break all typescript uses of getTransaction, since everything then needs a check if it is not null.

Code that uses getTransaction has to check for null since it will otherwise crash for dropped transactions. Existing code that does not do this is wrong, I was just bitten by this. Correcting the TypeScript types is not a breaking change, it’s a bug fix

1reaction
ricmoocommented, Jun 28, 2022

That should be fine. I don’t see any issue with using that to isolate it to your own project. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

getTransaction returns null for some pendingTransactions ...
I am doing getTransaction for each received pendingTransaction like below. web3.eth.subscribe('pendingTransactions', function(error, txnid) { ...
Read more >
eth.getTransactionReceipt returns null - Stack Overflow
It looks like there's an issue with your node. The receipt is returned from Infura. I'd recommend resync without --fast .
Read more >
Consistent API design - Akshay Jain
Suppose we have an API /getTransaction with following response ... Getting null as a value for transactionComments from API, ... Write on Medium ......
Read more >
Error getting transaction data for Transaction Number: 1 ...
Error getting transaction data for Transaction Number: 1. Value cannot be null. Parameter name: source at Source: Message box.
Read more >
eth getTransactionReceipt returns null | Edureka Community
... a blockchain explorer, but our Eth fullnode seems to be missing . ... eth getTransactionReceipt returns null ... getTransaction but eth.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found