Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in error message #1047

Closed
zemse opened this issue Sep 15, 2020 · 4 comments
Closed

Change in error message #1047

zemse opened this issue Sep 15, 2020 · 4 comments
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@zemse
Copy link
Collaborator

zemse commented Sep 15, 2020

Sorry to bother about errors again, but error messages just went from readable to unreadable.

I have two error messages of a same script, before and post ethers.js minor upgrade (i've added quick new line characters to make it viewable here instead of horizontal scroll)

Some previous version (web/5.0.2):

processing response error (body={"jsonrpc":"2.0","error":{"code":-32010,"message":"Transaction nonce is too low. Try 
incrementing the nonce."},"id":44}, error=
{"code":-32010}, requestBody="{\"method\":\"eth_sendRawTransaction\",\"params\":
[\"0xf9016a828334808301a012944cada3b127fd31921127409a86a71d0a7cb7a85b80b90104e60e2b52000000000000000
000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000
0000000000000000000100000000000000000000000016c487299760dd3383f188249a4d873d3e29f391000000000000
000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000
0000000000000000003dfcb407b3e3817427649829cb1b4b0eeba4b65e00000000000000000000000000000000000000
000000000000000000000000008228bca0b90cfbeebbee57a0179252d61fb028f878f7b00f6468d5399e15ab225ed5c7e8a
031af41679a9e868af5d02c67accab79e61b5356d63c554bd9c9b829a9acbc521\"],\"id\":44,\"jsonrpc\":\"2.0\"}", 
requestMethod="POST", url="https://infura.io", code=SERVER_ERROR, version=web/5.0.2)

Latest version (web/5.0.6):

processing response error (body="0x7b226a736f6e727063223a22322e30222c226572726f72223a7b22636f6465223a2d33323031302c226d657373
616765223a225472616e73616374696f6e206e6f6e636520697320746f6f206c6f772e2054727920696e6372656d656e746
96e6720746865206e6f6e63652e227d2c226964223a333634337d0a", error={"code":-32010}, requestBody="
{\"method\":\"eth_sendRawTransaction\",\"params\":
[\"0xf9016a828334808301a012944cada3b127fd31921127409a86a71d0a7cb7a85b80b90104e60e2b52000000000000000
000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000
0000000000000000000100000000000000000000000016c487299760dd3383f188249a4d873d3e29f391000000000000
000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000
0000000000000000003dfcb407b3e3817427649829cb1b4b0eeba4b65e00000000000000000000000000000000000000
000000000000000000000000008228bca0b90cfbeebbee57a0179252d61fb028f878f7b00f6468d5399e15ab225ed5c7e8a
031af41679a9e868af5d02c67accab79e61b5356d63c554bd9c9b829a9acbc521\"],\"id\":3643,\"jsonrpc\":\"2.0\"}", 
requestMethod="POST", url="https://infura.io", code=SERVER_ERROR, version=web/5.0.6)

Before the upgrade, I could simply do if(error.message.includes('Transaction nonce is too low')) {} in my logic. Now the body is not parsed format.

Also I wanted to know a good way to install an older version of ethers (downgrade few minor versions) incase situation is very critical and it's super urgent to get it working no matter what.

@ricmoo
Copy link
Member

ricmoo commented Sep 15, 2020

That is strange. It is encoding it as hex (decoded: '{"jsonrpc":"2.0","error":{"code":-32010,"message":"Transaction nonce is too low. Try incrementing the nonce."},"id":3643}\n').

I'll figure out why this is happening and fix it shortly.

You shouldn't need any string matching. When things are working correctly, you should be able to use if (error.code === Logger.errors.NONCE_EXPIRED) { } to accomplish the same thing, and then ethers can be responsible for normalizing the errors. :)

@zemse
Copy link
Collaborator Author

zemse commented Sep 16, 2020

You shouldn't need any string matching. When things are working correctly, you should be able to use if (error.code === Logger.errors.NONCE_EXPIRED) { } to accomplish the same thing, and then ethers can be responsible for normalizing the errors. :)

That's really awesome!

@ricmoo
Copy link
Member

ricmoo commented Sep 17, 2020

This should be available in 5.0.14 now. :)

I found the code path that was skipping the human-readability of error messages in some cases and updated the string matching for normalizing the errors and making sure the Signer and FallbackProvider properly forward blockchain errors.

Let me know if you have any problems. :)

@ricmoo ricmoo added bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published. labels Sep 17, 2020
@ricmoo
Copy link
Member

ricmoo commented Sep 23, 2020

Closing this now, but please re-open if you are still having issues.

Thanks! :)

@ricmoo ricmoo closed this as completed Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants