@@ -19,28 +19,45 @@ async function runTeardown() {
1919 return false ;
2020 }
2121
22- try {
23- const res = await fetch ( e2eTestApi , {
24- body : JSON . stringify ( { } ) ,
25- headers : {
26- 'Accept' : 'application/json' ,
27- 'Content-Type' : 'application/json' ,
28- 'X-E2E-Test-Auth-Token' : token . trim ( ) ,
29- } ,
30- method : 'POST' ,
31- } ) ;
22+ const maxAttempts = 3 ;
23+ const delayMs = 2000 ; // 2 seconds between attempts
3224
33- if ( res . ok ) {
34- console . log ( '\x1b[32m%s\x1b[0m\n' , '✓ E2E teardown successful' ) ;
35- return true ;
36- } else {
37- console . error ( '\x1b[31m%s\x1b[0m\n' , `✗ E2E teardown failed: ${ res . status } ` ) ;
38- return false ;
25+ for ( let attempt = 0 ; attempt < maxAttempts ; attempt ++ ) {
26+ if ( attempt > 0 ) {
27+ console . log ( `\x1b[33m%s\x1b[0m` , `Retrying teardown (attempt ${ attempt + 1 } /${ maxAttempts } )...` ) ;
28+ await new Promise ( resolve => setTimeout ( resolve , delayMs ) ) ;
29+ }
30+
31+ try {
32+ const res = await fetch ( e2eTestApi , {
33+ body : JSON . stringify ( { } ) ,
34+ headers : {
35+ 'Accept' : 'application/json' ,
36+ 'Content-Type' : 'application/json' ,
37+ 'X-E2E-Test-Auth-Token' : token . trim ( ) ,
38+ } ,
39+ method : 'POST' ,
40+ } ) ;
41+
42+ if ( res . ok ) {
43+ console . log ( '\x1b[32m%s\x1b[0m\n' , '✓ E2E teardown successful' ) ;
44+ return true ;
45+ } else {
46+ console . error ( '\x1b[31m%s\x1b[0m' , `✗ E2E teardown failed: ${ res . status } ` ) ;
47+ if ( attempt < maxAttempts - 1 ) {
48+ console . log ( '' ) ; // newline before retry message
49+ }
50+ }
51+ } catch ( error ) {
52+ console . error ( '\x1b[31m%s\x1b[0m' , `✗ E2E teardown error: ${ error } ` ) ;
53+ if ( attempt < maxAttempts - 1 ) {
54+ console . log ( '' ) ; // newline before retry message
55+ }
3956 }
40- } catch ( error ) {
41- console . error ( '\x1b[31m%s\x1b[0m\n' , `✗ E2E teardown error: ${ error } ` ) ;
42- return false ;
4357 }
58+
59+ console . log ( '\x1b[31m%s\x1b[0m\n' , `✗ E2E teardown failed after ${ maxAttempts } attempts` ) ;
60+ return false ;
4461}
4562
4663function runPlaywright ( args : string [ ] , quietMode : boolean ) : boolean {
@@ -65,7 +82,8 @@ async function main() {
6582
6683 // Get additional args passed to the script (e.g., test file names, -g patterns)
6784 const extraArgs = process . argv . slice ( 2 ) ;
68- const quietMode = process . env . QUIET === '1' ;
85+ const verboseMode = process . env . VERBOSE === '1' ;
86+ const quietMode = ! verboseMode ;
6987
7088 while ( attempt <= RETRIES ) {
7189 if ( attempt > 0 ) {
0 commit comments