Fix "Cannot read properties of null (reading 'data')" issue when decoding error from ethers.js#11
Draft
randydu wants to merge 1 commit intosuperical:mainfrom
Draft
Fix "Cannot read properties of null (reading 'data')" issue when decoding error from ethers.js#11randydu wants to merge 1 commit intosuperical:mainfrom
randydu wants to merge 1 commit intosuperical:mainfrom
Conversation
The errorData could be null when the error is thrown from hardhat / ethers.js, hence a "Cannot read properties of null (reading 'data')" error will occur when setting returnData in the line 67.
Example error causing the issue:
```json
{
code: 'UNKNOWN_ERROR',
error: {
code: -32000,
message: "Nonce too high. Expected nonce to be 0 but got 33. Note that transactions can't be queued when automining.",
data: {
message: "Nonce too high. Expected nonce to be 0 but got 33. Note that transactions can't be queued when automining.",
data: null
}
},
payload: {
method: 'eth_sendRawTransaction',
params: [
'0x02f8b2827a6921843b9aca00843e9a078083015644944abeaca4b05d8fa4ced09d26ad28ea298e8afac880b844a9059cbb0000000000000000000000009965507d1a55bcc2695c58ba16fb37d819b0a4dc0000000000000000000000000000000000000000000000000000000000000064c001a03c032ec0cd43679f7400e1c90a8c9c07fe3d87ed4e0bf78ec5097046cf16d1eaa03cc5e482a939684ef216bfdeb72cb15fd36558a9df53de3745e3a27eb60f7869'
],
id: 28,
jsonrpc: '2.0'
},
shortMessage: 'could not coalesce error'
}
```
Author
|
I have not double checked if my fix really works for the error, it seems the error is not raised from line 67. Here is the stack trace when the error is thrown: |
Owner
|
Thanks @randydu for creating this pull request!😊 Just want to check if I understood the issue correctly, the issue you’re facing happens when the nonce is incorrectly passed to Ethers when sending a transaction and the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The errorData could be null when the error is thrown from hardhat / ethers.js, hence a "Cannot read properties of null (reading 'data')" error will occur when setting returnData at line 67.
Example error causing the issue: