-
Notifications
You must be signed in to change notification settings - Fork 259
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
ERR_UNHANDLED_REJECTION occurs in the method PosClient.isCheckPointed() #394
Comments
The error you're encountering is an "UnhandledPromiseRejection" error in Node.js, indicating that a promise rejection occurred but was not handled with a
To address this issue, you should properly handle promise rejections in your code to prevent unhandled promise rejection errors. Here's a modified version of your code with added error handling: const posClient = await getBridgeClient();
console.log(transactionReceipt.transactionHash);
try {
const isCheckPointed = await posClient.isCheckPointed(transactionReceipt.transactionHash);
console.log(`Hash: ${transactionReceipt.transactionHash} isCheckPointed: ${isCheckPointed}`);
if (isCheckPointed) {
const erc20RootToken = await getERC20RootToken();
await erc20RootToken.withdrawExit(transactionReceipt.transactionHash);
console.log(`${transactionReceipt.transactionHash} withdraw, txHash : ${transactionReceipt.transactionHash}`);
}
} catch (error) {
console.error("An error occurred:", error);
}
async function getBridgeClient() {
if (bridgeClient === null) {
bridgeClient = new POSClient();
const polygonConstructorArguments = {
privateKeys: ['...........................'],
providerOrUrl: '...................'
};
const etherConstructorArguments = {
privateKeys: ['........................'],
providerOrUrl: '...........'
};
try {
await bridgeClient.init({
network: 'testnet',
version: 'mumbai',
parent: {
provider: new HDWalletProvider(polygonConstructorArguments),
defaultConfig: {
from: Parent.from
}
},
child: {
provider: new HDWalletProvider(etherConstructorArguments),
defaultConfig: {
from: Child.from
}
}
});
} catch (error) {
console.error("An error occurred while initializing bridgeClient:", error);
}
}
return bridgeClient;
} Here's what I've done:
By adding these error handling blocks, you should be able to avoid the "UnhandledPromiseRejection" error and get more information about the specific error that's occurring in your code. Make sure to replace the |
Describe the bug
0x9cb0b04171ca692a156c174381c00f4ccebe543fcfcfbd865254f950f6778259
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#".
] {
code: 'ERR_UNHANDLED_REJECTION'
}
Node.js v18.16.0
Hint
My code:
const posClient = await getBridgeClient()
console.log(transactionReceipt.transactionHash)
const isCheckPointed = await posClient.isCheckPointed(transactionReceipt.transactionHash);
console.log(
hash: ${transactionReceipt.transactionHash} isCheckPointed: ${isCheckPointed}
)if(isCheckPointed){
const erc20RootToken = await getERC20RootToken()
await erc20RootToken.withdrawExit(transactionReceipt.transactionHash)
console.log(
${transactionReceipt.transactionHash} withdraw, txHash : ${transactionReceipt.transactionHash}
)}
const getBridgeClient = async () : Promise => {
if (bridgeClient === null) {
bridgeClient = new POSClient()
}
return bridgeClient
}
The text was updated successfully, but these errors were encountered: