Skip to content

Unable to catch errors some errors from the SDK in transactionBase.js #98

@trekze

Description

@trekze

For some reason I can't seem to gracefully recover from errors thrown in the SDK, despite using the .on("error" handler AND wrapping the send function a try catch block. Any ideas why that's the case? Sample code below:

try {
            let sendoptions = {
                from: from,
                gasLimit: '250000',
                gasPrice: new hmy.utils.Unit(GAS_PRICE_GWEI).asGwei().toWei(),
            };
            await contract.methods
                .transfer(to, new Unit(amount).asOne().toWei())
                .send(sendoptions)
                .on("transactionHash", (_hash) => {
                })
                .on("receipt", (_receipt) => {
                })
                .on("confirmation", (confirmation) => {

                })
                .on("error", (error) => {

                });
        } catch (err) {

        }

And the error that's taking down the process below:

17:33:59: Withdraw: send failure within Harmony, reverting balance for wallet 8271
17:33:59: REJECTED
/path/hidden/node_modules/@harmony-js/transaction/dist/transactionBase.js:202
                        throw new Error("The transaction is still not confirmed after " + maxAttempts + " attempts.");
                              ^

Error: The transaction is still not confirmed after 20 attempts.
    at Transaction.<anonymous> (/path/hidden/node_modules/@harmony-js/transaction/dist/transactionBase.js:202:31)
    at step (/path/hidden/node_modules/tslib/tslib.js:143:27)
    at Object.next (/path/hidden/node_modules/tslib/tslib.js:124:57)
    at fulfilled (/path/hidden/node_modules/tslib/tslib.js:114:62)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions