-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
const getVaa = async (initiatingChainId: number, initiatingHash: string) => {
try {
const wh = await getWh([initiatingChainId])
const chainName = toChain(chainConfig[initiatingChainId].portalChainId)
const srcChain = wh.getChain(chainName)
const [whm] = await srcChain.parseTransaction(initiatingHash)
const vaa = await wh.getVaa(whm, 'TokenBridge:Transfer', 0)
if (!vaa) {
return null
}
return vaa
} catch (e: Error) {
return e
}
}
Above fn is a slightly simplified version of one from my codebase
When the wormholescan API was down the other day this was throwing an uncaught exception after calling wh.getVaa and crashing the entire app. Chased it down with the debugger a little bit by modifying the url in node_modules to throw a similar exception.
Appears that something about the retry function is causing this error to happen outside the scope of this try.catch block. If I modify this in the tasks file to have a catch block (as below) it begins to be handled.
export async function retry(task, interval, timeout = DEFAULT_TASK_TIMEOUT, title) {
const maxRetries = Math.floor(timeout / interval);
let retries = 0;
return new Promise((resolve, reject) => {
task().then((result) => {
if (result !== null) {
resolve(result);
return;
}
let intervalId = setInterval(async () => {
if (retries >= maxRetries) {
clearInterval(intervalId);
resolve(null);
return;
}
const result = await task();
if (result !== null) {
clearInterval(intervalId);
resolve(result);
}
else if (title) {
console.log(`Retrying ${title}, attempt ${retries}/${maxRetries} `);
}
retries++;
}, interval);
}).catch((e) => {
reject(e)
});
});
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels