Skip to content

Commit

Permalink
increase gateway fetch retry count
Browse files Browse the repository at this point in the history
  • Loading branch information
NickJ202 committed Aug 30, 2024
1 parent 35f5d0b commit 2ea5e21
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/views/Upload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,9 @@ export default function Upload() {

let processId: string;
let retryCount = 0;
const maxRetries = 25;
const maxSpawnRetries = 25;

while (!processId && retryCount < maxRetries) {
while (!processId && retryCount < maxSpawnRetries) {
try {
processId = await aos.spawn({
module: AO.module,
Expand All @@ -458,16 +458,17 @@ export default function Upload() {
} catch (e: any) {
console.error(`Spawn attempt ${retryCount + 1} failed:`, e);
retryCount++;
if (retryCount < maxRetries) {
if (retryCount < maxSpawnRetries) {
await new Promise((r) => setTimeout(r, 1000));
} else {
throw new Error(`Failed to spawn process after ${maxRetries} attempts`);
throw new Error(`Failed to spawn process after ${maxSpawnRetries} attempts`);
}
}
}

let fetchedAssetId: string;
retryCount = 0;
const maxFetchRetries = 100;
while (!fetchedAssetId) {
await new Promise((r) => setTimeout(r, 2000));
const gqlResponse = await getGQLData({
Expand All @@ -486,8 +487,10 @@ export default function Upload() {
} else {
console.log(`Transaction not found:`, processId);
retryCount++;
if (retryCount >= 10) {
throw new Error(`Transaction not found after 10 attempts, process deployment retries failed`);
if (retryCount >= maxFetchRetries) {
throw new Error(
`Transaction not found after ${maxFetchRetries} attempts, process deployment retries failed`
);
}
}
}
Expand Down

0 comments on commit 2ea5e21

Please sign in to comment.