@@ -126,23 +126,30 @@ export class FreshFirefox implements Interceptor {
126126 async setupFirefoxProfile ( ) {
127127 const certCheckServer = new CertCheckServer ( this . config ) ;
128128 await certCheckServer . start ( ) ;
129- const certInstalled = certCheckServer . waitForSuccess ( ) . catch ( reportError ) ;
129+
130+ let certInstalled : Promise < void > | true = certCheckServer . waitForSuccess ( ) . catch ( reportError ) ;
130131
131132 certInstallBrowser = await this . startFirefox ( certCheckServer ) ;
132133 certInstallBrowser . process . once ( 'close' , ( ) => {
133134 certCheckServer . stop ( ) ;
134135 certInstallBrowser = undefined ;
136+ if ( certInstalled !== true ) {
137+ reportError ( 'Firefox certificate setup failed' ) ;
138+ deleteFolder ( this . firefoxProfilePath ) . catch ( console . warn ) ;
139+ }
135140 } ) ;
141+
136142 await certInstalled ;
143+ certInstalled = true ;
144+
137145 await delay ( 100 ) ; // Tiny delay, so firefox can do initial setup tasks
138146 certInstallBrowser . stop ( ) ;
139147 }
140148
141149 async activate ( proxyPort : number ) {
142150 if ( this . isActive ( proxyPort ) || ! ! certInstallBrowser ) return ;
143151
144- const firefoxProfile = path . join ( this . config . configPath , 'firefox-profile' ) ;
145- const firefoxPrefsFile = path . join ( firefoxProfile , 'prefs.js' ) ;
152+ const firefoxPrefsFile = path . join ( this . firefoxProfilePath , 'prefs.js' ) ;
146153
147154 let existingPrefs : _ . Dictionary < any > = { } ;
148155
@@ -188,7 +195,7 @@ export class FreshFirefox implements Interceptor {
188195 delete browsers [ proxyPort ] ;
189196 if ( ! success ) {
190197 reportError ( 'Firefox certificate check failed' ) ;
191- deleteFolder ( firefoxProfile ) . catch ( console . warn ) ;
198+ deleteFolder ( this . firefoxProfilePath ) . catch ( console . warn ) ;
192199 }
193200 } ) ;
194201
0 commit comments