-
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
Errors not caught in 4.x #6500
Comments
Hello @trystendsmyth , Actually,
Please, close this issue if this resolved your problem. |
@Muhammad-Altabba in my example, I'm am already awaiting the promise and registering events to it as you're suggesting. However, I tried your approach of awaiting the promise after setting registering events, but unfortunately that didn't make a difference. Also, as I mentioned, my example works on 1.x - is there a substantial way that this promise event handling changed? |
Hi @jdevcs , I am having the exact same experience as @trystendsmyth . How should errors be handled in this case with version 4+? I have a codesandbox demo where this behavior is replicated. Note that the After making the call I see polling is happening, and after a while the TransactionBlockTimeoutError: Transaction started at 5947380 but was not mined within 50 blocks. Please make sure your transaction was properly sent and there no pervious pending transaction for the same account. However, be aware that it might still be mined!
Transaction Hash: not available To recap, the error Thank you! |
@am-hernandez Thanks, we will fix it. cc: @mconnelly8 |
Hi @jdevcs , Would you please let us know if there is an ETA for this resolution? Thank you. |
Hi @am-hernandez its on top of list for next sprint starting tomorrow. cc: @mconnelly8 |
I investigated it didn't fully reproduce a problem. I've found and fix a problem with catching @am-hernandez - your code doesn't have try-catch structure - that's why it fails Also, I've added tests to check some cases that you described:
@am-hernandez ,@trystendsmyth Please check these code examples and if you still have a problem please give me steps to reproduce. Thank you, guys, again for your contribution |
@trystendsmyth I've checked your code again and run it locally with web3js provider import {Web3} from 'web3'
const rpcUrl = "https://mainnet.base.org/";
const web3 = new Web3(rpcUrl);
const abi = [
{
inputs: [],
name: "fee",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "uint8[]",
name: "tileIndexes",
type: "uint8[]",
},
{
internalType: "uint8[]",
name: "tileBufferIndexes",
type: "uint8[]",
},
{
internalType: "uint8[]",
name: "values",
type: "uint8[]",
},
],
name: "put",
outputs: [],
stateMutability: "payable",
type: "function",
},
];
const contract = new web3.eth.Contract(
abi,
"0x44fE343FCE6458da253e700ceE0a55449aEa8E18",
);
const test = async () => {
const account = await web3.eth.accounts.create();
const fee = await contract.methods.fee().call();
console.log(`Fetched fee ${fee}`);
// @ts-ignore
const web3PromiEvent = contract.methods.put([0], [0], [0xf]).send({
from: account.address,
// @ts-ignore
value: fee,
});
web3PromiEvent
.on("sending", (sending) => {
console.log("sending:", sending);
})
.on("sent", (sent) => {
console.log("sending:", sent);
})
.on("transactionHash", (hash) => {
console.log("Transaction hash:", hash);
})
.on("error", (err) => {
console.log("on error:", err);
}).then((receipt) => {
console.log("Transaction receipt:", receipt);
}).catch((error) => {
console.log("Transaction ERROR:");
console.error(error);
})
}
test() and it works. So looks like the problem inside |
@avkos in my example, I'm not referencing any single provider. However even if I was, I'm not sure I see how that would prevent error catching in |
The following test code was written to demonstrate the observed issue.
Expected behavior
In 1.x OR 4.x versions of Web3.js, errors should be caught by either the
on('error')
or thecatch
.Actual behavior
In 1.x, when there is (for instance) an "insufficient funds" error, it is caught by the
on('error')
handler.In 4.x, errors are not caught by the handler or
catch
, and cause the application to crash.Steps to reproduce the behavior
4.1.2
Environment
Node 18
Web3.js 4.1.2
MacOS
Chrome
The text was updated successfully, but these errors were encountered: