@@ -264,17 +264,21 @@ export abstract class BrowserType extends SdkObject {
264
264
close : ( ) => closeOrKill ( ( options as any ) . __testHookBrowserCloseTimeout || DEFAULT_PLAYWRIGHT_TIMEOUT ) ,
265
265
kill
266
266
} ;
267
- progress . cleanupWhenAborted ( ( ) => closeOrKill ( DEFAULT_PLAYWRIGHT_TIMEOUT ) ) ;
268
- const { wsEndpoint } = await progress . race ( [
269
- this . waitForReadyState ( options , browserLogsCollector ) ,
270
- exitPromise . then ( ( ) => ( { wsEndpoint : undefined } ) ) ,
271
- ] ) ;
272
- if ( options . cdpPort !== undefined || ! this . supportsPipeTransport ( ) )
273
- transport = await WebSocketTransport . connect ( progress , wsEndpoint ! ) ;
274
- else
275
- transport = new PipeTransport ( processLifecycleHooks . writePipe ( launchedProcess ) , processLifecycleHooks . readPipe ( launchedProcess ) ) ;
276
- progress . cleanupWhenAborted ( ( ) => transport . close ( ) ) ;
277
- return { browserProcess, artifactsDir : prepared . artifactsDir , userDataDir : prepared . userDataDir , transport } ;
267
+ try {
268
+ const { wsEndpoint } = await progress . race ( [
269
+ this . waitForReadyState ( options , browserLogsCollector ) ,
270
+ exitPromise . then ( ( ) => ( { wsEndpoint : undefined } ) ) ,
271
+ ] ) ;
272
+ if ( options . cdpPort !== undefined || ! this . supportsPipeTransport ( ) )
273
+ transport = await WebSocketTransport . connect ( progress , wsEndpoint ! ) ;
274
+ else
275
+ transport = new PipeTransport ( processLifecycleHooks . writePipe ( launchedProcess ) , processLifecycleHooks . readPipe ( launchedProcess ) ) ;
276
+ return { browserProcess, artifactsDir : prepared . artifactsDir , userDataDir : prepared . userDataDir , transport } ;
277
+ } catch ( error ) {
278
+ transport ?. close ( ) ;
279
+ await closeOrKill ( DEFAULT_PLAYWRIGHT_TIMEOUT ) . catch ( ( ) => { } ) ;
280
+ throw error ;
281
+ }
278
282
}
279
283
280
284
async _createArtifactDirs ( options : types . LaunchOptions ) : Promise < void > {
0 commit comments