Describe the bug
After siging tx (Confirm button) throws "code":-32603,"message":"TypeError: Cannot read property 'number' of null
Screenshots


Browser details (please complete the following information):
Additional context
I've got this error for the second time in my life. No idea how to reproduce this again.
@mqklin what site/dapp were you using when you encountered this error? any tips on how to reproduce?
@bdresser I used Zerion (https://beta.zerion.io), called sendTransaction (interacted with Compound - Lend tab on Zerion). But, as I said, it's very rare, and I can't reproduce this again.
I've also encountered this in our in-house app.
@frankiebee does this stand out to you? I'd guess a block is null somewhere?
Responses from Infura are very ofter null , that's why we've created this wrapper:
export default async function handleNodeNullResponse(response, [f, args = []], responseTransformer = () => response) {
if (response === null) {
await sleep(3000);
return f(...args);
}
return responseTransformer(response);
}
Then call:
async function getEthExchangeRate() {
const contract = w3u.createContract(cETH.ABI, cETH.address);
return handleNodeNullResponse(
await contract.methods.exchangeRateCurrent().call(),
[getEthExchangeRate],
BigNumber,
);
}
const ethExchangeRate = await getEthExchangeRate();
For getBlock we just use
async function getBlock(...args) {
const block = await web3.eth.getBlock(...args);
if (block === null) {
return getBlock(...args);
}
return block;
}
yeah most likely the number is null it would be nice to know at what point it failed and having the debug history for the transaction would be very useful
@mqklin if you could get your mm state and send it to [email protected] referencing this issue number it would be a lot of help!
To help us diagnose your issue, you can download your "state logs" by following this guide, and then sending them to [email protected] .
I've already done this! If I encounter this problem again, I'll immediately send you the logs
@danfinlay I've just got this error again, sent logs to [email protected], please check!
I've reproduced this issue a couple of times, though quite sporadically, over the last few days. I sent my metamask state logs to [email protected].
related support cases: 22367 and 22432
I also just saw this issue. Restarting Chrome seemed to fix it.
has anyone been able to consistently reproduce this error?
This bug makes me want to convert our tx managing files over to typescript, since it is very stubborn about leaving code paths open that could allow things like trying to access a property on an undefined value.
@danfinlay, would be amazing if you guys did manage the error in metamask -- we have implemented a wrapper to catch rpc errors but ideally we would love to not have to wrap every function call in a retry catch block :)
Same issue here:
"code":-32603,"message":"TypeError: Cannot read property 'number' of null.

Environment: Mac, Chrome, MetaMask 7.1.1
The issue appears randomly. I have seen it at least 10 times already. Haven't figured out how to reproduce.
I just ran into this bug too while using ganache-cli, so I don't think it's an issue with Infura returning null. Restarting Chrome fixed it, but I have no idea what caused it.
Looks like I can recreate it by turning off a previously connected instance of ganache-cli and starting it up again while not restarting Chrome.
This happens when switching MetaMask accounts and attempting to send a transaction through the dApp without first reloading the tab.
Reloading the tab is necessary on some dApps which initialize the selected account once when the page loads and do not subscribe to the web3 provider's changes. Thus they are trying to send a transaction from an unselected account.
In my apps, I use this snippet to subscribe to MetaMask changes:
(Edit: See danfinlay's comment for a better solution)
web3.currentProvider.publicConfigStore.on('update', (out) => {
console.log('Selected address', out.selectedAddress)
// Do something with out.selectedAddress here
})
You will notice this runs even when the user opens MetaMask and closes it without changing anything. Depending on how you handle account changes, you might need to check if out.selectedAddress is the same as the old address you have saved in some variable.
That is an internal API and is prone to random change. I recommend using the supported EIP-1193 compatible event listener ethereum.on('accountsChanged', handler):
https://metamask.github.io/metamask-docs/API_Reference/Ethereum_Provider#ethereum.on(eventname%2C-callback)
Here a solution that I applied after reading the above comments and it worked. I closed the chrome and restart it and finally that error is gone.
So, I think this error arose as I've opened, added or switched to so many accounts in metamask. this may be the reason for you, you can try .
Going to close this, as there have been changes to the aforementioned parts of code that this error could have originated from. If anyone is continuing to get this error please open a new issue with enough information to reproduce your issue.
Most helpful comment
That is an internal API and is prone to random change. I recommend using the supported EIP-1193 compatible event listener
ethereum.on('accountsChanged', handler):https://metamask.github.io/metamask-docs/API_Reference/Ethereum_Provider#ethereum.on(eventname%2C-callback)