Skip to content

Commit 140b6cb

Browse files
committed
feat: add retry loop to devnet check
1 parent daad111 commit 140b6cb

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

run/test/specs/utils/devnet.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { buildStateForTest } from '@session-foundation/qa-seeder';
2+
import { execSync } from 'child_process';
23
import request from 'sync-request-curl';
34

45
import type { SupportedPlatformsType } from './open_app';
@@ -14,18 +15,32 @@ type NetworkType = Parameters<typeof buildStateForTest>[2];
1415
// Using sync HTTP here to avoid cascading async changes through test init
1516
// This runs at test startup, so blocking is acceptable
1617
function canReachDevnet(): boolean {
18+
const isCI = process.env.CI === '1';
19+
const maxAttempts = isCI ? 3 : 1;
20+
const timeout = isCI ? 10_000 : 2_000;
1721
// Check if devnet is available
18-
try {
19-
const response = request('GET', DEVNET_URL, {
20-
timeout: 2000,
21-
});
22+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
23+
try {
24+
if (maxAttempts > 1) {
25+
console.log(`Checking devnet accessibility (attempt ${attempt}/${maxAttempts})...`);
26+
}
2227

23-
console.log(`Internal devnet is accessible (HTTP ${response.statusCode})`);
24-
return true;
25-
} catch {
26-
console.log('Internal devnet is not accessible');
27-
return false;
28+
const response = request('GET', DEVNET_URL, { timeout });
29+
console.log(`Internal devnet is accessible (HTTP ${response.statusCode})`);
30+
return true;
31+
} catch (error) {
32+
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
33+
34+
if (attempt === maxAttempts) {
35+
console.log(`Internal devnet is not accessible: ${errorMsg}`);
36+
} else {
37+
console.log(`Attempt ${attempt} failed: ${errorMsg}, retrying...`);
38+
execSync(`sleep ${attempt}`);
39+
}
40+
}
2841
}
42+
43+
return false;
2944
}
3045
function isAutomaticQABuildAndroid(apkPath: string): boolean {
3146
// Check env var first (for CI), then filename (for local)

0 commit comments

Comments
 (0)