Skip to content

Commit

Permalink
fix: subgraph fallbacks (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmbronco authored Sep 12, 2024
1 parent 9d9b90d commit f1cc1c9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/sources/subgraphs/retry-on-failure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ export async function retryOnFailureWithRotation<T>(
return await fn(sdk); // Try the operation using the current SDK
} catch (error) {
attempts += 1;
console.error(`Subgraph failed ${new URL(sdkClients[currentSdkIndex].url).host}:`, error);
console.log(`Subgraph URL from index ${currentSdkIndex} on ${attempts + 1} attempt failed:`, error);
console.error(`Subgraph failed:`, error);

if (attempts < retries) {
// Rotate to the next SDK client
currentSdkIndex = (currentSdkIndex + 1) % sdkClients.length;
console.log(`Retrying with ${new URL(sdkClients[currentSdkIndex].url).host}...`);
console.log(`Retrying with URL from index ${currentSdkIndex}...`);
} else {
throw new Error('All SDK clients failed after retries.');
}
Expand Down

0 comments on commit f1cc1c9

Please sign in to comment.