11import { buildStateForTest } from '@session-foundation/qa-seeder' ;
2+ import { execSync } from 'child_process' ;
23import request from 'sync-request-curl' ;
34
45import 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
1617function 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}
3045function isAutomaticQABuildAndroid ( apkPath : string ) : boolean {
3146 // Check env var first (for CI), then filename (for local)
0 commit comments