@@ -62,8 +62,6 @@ export function jestTestMCPClient(): () => Client {
62
62
export function jestTestCluster ( ) : ( ) => runner . MongoCluster {
63
63
let cluster : runner . MongoCluster | undefined ;
64
64
65
- function runMongodb ( ) { }
66
-
67
65
beforeAll ( async function ( ) {
68
66
// Downloading Windows executables in CI takes a long time because
69
67
// they include debug symbols...
@@ -72,7 +70,7 @@ export function jestTestCluster(): () => runner.MongoCluster {
72
70
73
71
// On Windows, we may have a situation where mongod.exe is not fully released by the OS
74
72
// before we attempt to run it again, so we add a retry.
75
- const dbsDir = path . join ( tmpDir , "mongodb-runner" , ` dbs` ) ;
73
+ let dbsDir = path . join ( tmpDir , "mongodb-runner" , " dbs" ) ;
76
74
for ( let i = 0 ; i < 10 ; i ++ ) {
77
75
try {
78
76
cluster = await MongoCluster . start ( {
@@ -83,10 +81,21 @@ export function jestTestCluster(): () => runner.MongoCluster {
83
81
84
82
return ;
85
83
} catch ( err ) {
86
- console . error ( `Failed to start cluster in ${ dbsDir } , attempt ${ i } : ${ err } ` ) ;
87
- await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
84
+ if ( i < 5 ) {
85
+ // Just wait a little bit and retry
86
+ console . error ( `Failed to start cluster in ${ dbsDir } , attempt ${ i } : ${ err } ` ) ;
87
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
88
+ } else {
89
+ // If we still fail after 5 seconds, try another db dir
90
+ console . error (
91
+ `Failed to start cluster in ${ dbsDir } , attempt ${ i } : ${ err } . Retrying with a new db dir.`
92
+ ) ;
93
+ dbsDir = path . join ( tmpDir , "mongodb-runner" , `dbs${ i - 5 } ` ) ;
94
+ }
88
95
}
89
96
}
97
+
98
+ throw new Error ( "Failed to start cluster after 10 attempts" ) ;
90
99
} , 120_000 ) ;
91
100
92
101
afterAll ( async function ( ) {
0 commit comments