Skip to content

Commit

Permalink
ref: add retry to testnet lookup for docker testnig
Browse files Browse the repository at this point in the history
  • Loading branch information
joshLong145 committed Jul 11, 2024
1 parent 4f25217 commit ba53c07
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions local-tests/setup/shiva-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {

import http from 'node:http';
import https from 'node:https';
import { error } from 'node:console';

const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });
Expand Down Expand Up @@ -252,11 +253,22 @@ export class ShivaClient {
async startTestnetManager(
createReq?: TestNetCreateRequest
): Promise<TestnetClient> {
const existingTestnetResp = await fetch(
this.processEnvs.TESTNET_MANAGER_URL + '/test/get/testnets',
//@ts-ignore
{agent: agentSelector}
);
let existingTestnetResp = undefined;
let retryCount = 0;
while (!existingTestnetResp && retryCount < 100) {
try{
existingTestnetResp = await fetch(
this.processEnvs.TESTNET_MANAGER_URL + '/test/get/testnets',
//@ts-ignore
{agent: agentSelector}
);
} catch (e) {
console.error('error while fetching testnets: ', error);
retryCount += 1;
await new Promise((res) => setTimeout(res, 1000));
}
}

const existingTestnets: string[] = await existingTestnetResp.json();
if (existingTestnets.length > 0) {
this._clients.set(
Expand Down

0 comments on commit ba53c07

Please sign in to comment.