Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Error: "n.data.substring is not a function", when setting web.eth.handleRevert = true #5999

@Muhammad-Altabba

Description

@Muhammad-Altabba

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When setting web.eth.handleRevert = true and calling any Smart Contract method that reverts with an error:
The following error is raised: "n.data.substring is not a function".

Expected Behavior

To return an error that contains the actual error from the Smart Contract.

Steps to Reproduce

The full details are at: #5677 (comment)

Web3.js Version

1.8.2

Environment

No response

Anything Else?

The current version of the Infura provider seems to be updated to put the error inside data.data. And here is what the internal object looks like with Infura:
image

And so we need to update web3.js to handle this. And here is the line that needs to be changed:

reasonData = err.data.substring(10);

And it could be changed to something like:

    reasonData = (err.data.data || err.data).substring(10);

Metadata

Metadata

Labels

1.x1.0 related issuesBugAddressing a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions