@@ -145,23 +145,33 @@ Given(
145145 fs . rmSync ( appDataPath , { recursive : true , force : true } ) ;
146146
147147 const nodeInstance = new MockOTNode ( nodeConfiguration ) ;
148- await nodeInstance . start ( ) ; // This will skip startNetworkModule
148+
149+ try {
150+ await nodeInstance . start ( ) ; // This will skip startNetworkModule
149151
150- const client = new DkgClientHelper ( {
151- endpoint : 'http://localhost' ,
152- port : rpcPort ,
153- useSSL : false ,
154- timeout : 25 ,
155- loglevel : 'trace' ,
156- } ) ;
152+ const client = new DkgClientHelper ( {
153+ endpoint : 'http://localhost' ,
154+ port : rpcPort ,
155+ useSSL : false ,
156+ timeout : 25 ,
157+ loglevel : 'trace' ,
158+ } ) ;
157159
158- this . state . bootstraps . push ( {
159- client,
160- otNodeInstance : nodeInstance ,
161- configuration : nodeConfiguration ,
162- nodeRpcUrl : `http://localhost:${ rpcPort } ` ,
163- fileService : nodeInstance . fileService ,
164- } ) ;
160+ this . state . bootstraps . push ( {
161+ client,
162+ otNodeInstance : nodeInstance ,
163+ configuration : nodeConfiguration ,
164+ nodeRpcUrl : `http://localhost:${ rpcPort } ` ,
165+ fileService : nodeInstance . fileService ,
166+ } ) ;
167+ } catch ( error ) {
168+ // Ensure node is stopped if there's an error after starting
169+ this . logger . error ( `Error during bootstrap initialization: ${ error . message } ` ) ;
170+ if ( nodeInstance . stop ) {
171+ await nodeInstance . stop ( ) ;
172+ }
173+ throw error ;
174+ }
165175 }
166176) ;
167177//
0 commit comments