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

The error cannot be caught, and the process is terminated directly. #4947

Open
lanlingxiawu opened this issue Feb 13, 2025 · 0 comments
Open
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@lanlingxiawu
Copy link

Ethers Version

6.12.0

Search Terms

No response

Describe the Problem

Image

Code Snippet

const tx = await routerContract.swapExactETHForTokensSupportingFeeOnTransferTokens(
            outMinAmount.toString(), path, signer.address, timestamp, { value: buyAmount.toString(), gasLimit: gasLimit, gasPrice:gasPrice.toString() });
        return await waitTx(tx);


async function waitTx(tx: any, retry: number = 10) {
    while(retry > 0) {
        try{
            const ret = await tx.wait();
            return ret;
        }catch(err: any){
            if(err.toString().indexOf("TypeError: Failed to fetch") != -1) {
                console.log("网络异常 err:" + err);
                console.log(`等待10s后重试, retry:${retry}`);
                await sleep(10000);
                retry--;
            } else {
                throw err;
            }
        }
    }
    return {
        type: 0,
        status: 0,
        hash: tx.hash,
    };
}

Contract ABI

Errors

Environment

No response

Environment (Other)

No response

@lanlingxiawu lanlingxiawu added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants