-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Uncaught TypeError: err.data.substring is not a function #3742
Comments
Hi there, the bug you're describing makes sense, do you have example code we can use to debug? Thank you for reporting this! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
Sorry but this bug was not fixed |
The bug seems to have been introduced on version 1.2.10 and still exist on 1.3.3.
|
Seeing the same issue. In our case it occurs when we provide an rpc url that
|
The `TokenGeyser.unstakeQuery` throws an error in case when eg. the amount param is greater than real user's stake or when the user stakes KEEP in block `X` and call unstakeQuery in block `X` (`SafeMath: division by zero` error is thrown.). The web3 parses the error message in the wrong way when the `hanleRevert` option is enabled [1]. So here we clone the rewards contract instance and disable the `hanldeRevert` option. References: [1]: web3/web3.js#3742
Encountered this issue as well and had to turn the 'handleRevert' property on the web3 provider to false like @gabmontes meantioned. I would like to use the revert reason feature but this error crashes the whole application and I was unable to catch it with a try-catch around 'await myMethod.send(...)'. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment. |
Hey bot, do not close this. The bug is not resolved yet. |
The bug is not resolved yet. |
Hello, encountering the same bug on latest web3, specifically in the transaction callback when calling a uint256 value from the contract:
Uncaught TypeError: err.data.substring is not a function
|
Just another data point, I wound up encountering this while developing in truffle, and I simplified a contract method to:
And then I try to execute that function and I get...
|
Bug still persists |
Bug still present. Any ETA on resolution? |
bump |
Getting this error when running |
Bump! Getting this error. Log:
|
bump |
I am able to reproduce the error with following contract CallRevert{
uint speed;
function Start(uint _speedPercent) public {
console.log("Start called:", _speedPercent);
require(_speedPercent <= 100, "speed invalid");
speed = _speedPercent;
}
} const CallRevert = artifacts.require("CallRevert");
describe("Call Error on Revert", function () {
let accounts;
let contract;
before(async function () {
accounts = await web3.eth.getAccounts();
const c = await CallRevert.new();
contract = new web3.eth.Contract(c.abi, c.address);
});
describe("Call Revert", function () {
it("should throw error when called", async function () {
contract.handleRevert = true;
await expect(contract.methods.Start(102).call()).to.be.rejectedWith('speed invalid');
});
it("should throw error when sent", async function () {
contract.handleRevert = true;
await expect(contract.methods.Start(102).send({from: accounts[0]})).to.be.rejectedWith('speed invalid');
});
});
}); The actual error object that appears with Ganahe is.
|
The actual response that is sent by the client is:
|
The further investigation leads to the fact that latest version of The following scripts confirms that if we use Start the
And use following contract and compile it.
Run following script. const Web3 = require("web3");
const web3 = new Web3(Web3.givenProvider || "http://localhost:8545");
const CallRevert = require("../artifacts/contracts/CallRevert.sol/CallRevert.json");
(async () => {
console.log("%%%%% WEB3: ", web3.version);
const account = web3.eth.accounts.create("my-pass-phrase");
web3.eth.accounts.wallet.add(account);
const accounts = await web3.eth.getAccounts();
await web3.eth.sendTransaction({
from: accounts[0],
to: account.address,
value: web3.utils.toWei("1234", "ether"),
});
console.log(
"%%%%% account balance: ",
await web3.eth.getBalance(account.address)
);
const contract = new web3.eth.Contract(CallRevert.abi, {
data: CallRevert.bytecode,
});
const contractInstance = await contract
.deploy({
arguments: [],
})
.send({
from: account.address,
gas: 1500000,
gasPrice: "30000000000000",
});
console.log("%%%%% contract address: ", contractInstance.options.address);
contractInstance.handleRevert = true;
await contractInstance.methods.Start(102).call();
})().catch((e) => {
console.error("%%%%% catches error: ", e);
}); It will produce following output.
The above output confirms that |
@gabmontes I am closing this issues after above verification. Feel free to open it if you get more traceable data or you can reproduce it with latest version of |
@nazarhussain thanks for the investigative work but I still see an issue ( |
@nicos99 I am pretty confident that problem is somewhere between Genache or Metamask provider. Try your code directly connecting with the local running node. If you can find more insights and share some script without external providers then feel free to re-open this issue. |
@nazarhussain ok, I will. However note that it is enough to only change the web3 version to 1.2.9 (with |
Same issue here:
Environment: No issues when using web3@1.2.9 |
Bump, still no fix yet the issue has been closed.
Code at the specified file & line:
Where Web3 version: 1.6.1 |
iam using "https://bsc-dataseed.binance.org/" and get the error on 1.7.0
when i set handleRevert to true metamask goes crazy and make errors every second right after i send the contract method |
I am experiencing the same behavior. I see this is now closed - what was the resolution? Thanks. |
The following line throws an Uncaught TypeError:
https://github.com/ethereum/web3.js/blob/4615f2d35c455bd81cb04f0ab8d8d2c0b140e33a/packages/web3-core-method/src/index.js#L630
The error is only thrown when
handleRevert
is activated in the contract and the transaction reverts. In that caseerr.data
is an object with this format:{name, stack, 0x...: {error, program_counter, return} }
. IfhandleRevert
isfalse
, thenerr.data
is a string and it is properly parsed.Using Geth 1.9, ganache-cli@6.8.2 and web3@1.3.0.
The text was updated successfully, but these errors were encountered: