@@ -34,8 +34,6 @@ export class CriticalStartupErrorHandler {
3434
3535 #onLivenessCheckCompleted?: ( ) => void ;
3636
37- #errorDisplayed = false ;
38-
3937 /**
4038 * Creates an instance of CriticalStartupErrorHandler.
4139 * This class listens for critical startup errors from the background script
@@ -68,17 +66,13 @@ export class CriticalStartupErrorHandler {
6866 try {
6967 await Promise . race ( [ livenessCheck , timeoutPromise ] ) ;
7068 } catch ( error ) {
71- // Only display error if we haven't already displayed one
72- if ( ! this . #errorDisplayed) {
73- this . #errorDisplayed = true ;
74- await displayCriticalError (
75- this . #container,
76- CriticalErrorTranslationKey . TroubleStarting ,
77- // This cast is safe because `livenessCheck` can't throw, and `timeoutPromise` only throws an
78- // error.
79- error as ErrorLike ,
80- ) ;
81- }
69+ await displayCriticalError (
70+ this . #container,
71+ CriticalErrorTranslationKey . TroubleStarting ,
72+ // This cast is safe because `livenessCheck` can't throw, and `timeoutPromise` only throws an
73+ // error.
74+ error as ErrorLike ,
75+ ) ;
8276 } finally {
8377 clearTimeout ( this . #livenessCheckTimeoutId) ;
8478 }
@@ -107,9 +101,7 @@ export class CriticalStartupErrorHandler {
107101 if ( method === BACKGROUND_LIVENESS_METHOD ) {
108102 if ( this . #onLivenessCheckCompleted) {
109103 this . #onLivenessCheckCompleted( ) ;
110- } else if ( ! this . #errorDisplayed) {
111- // Only display error if we haven't already displayed one and liveness check wasn't initialized
112- this . #errorDisplayed = true ;
104+ } else {
113105 await displayCriticalError (
114106 this . #container,
115107 CriticalErrorTranslationKey . TroubleStarting ,
@@ -133,22 +125,13 @@ export class CriticalStartupErrorHandler {
133125 hasBackup : boolean ;
134126 currentLocale ?: string ;
135127 } ;
136- // Only display error if we haven't already displayed one
137- if ( ! this . #errorDisplayed) {
138- this . #errorDisplayed = true ;
139- // Cancel the liveness check since we're displaying a corruption error
140- clearTimeout ( this . #livenessCheckTimeoutId) ;
141- if ( this . #onLivenessCheckCompleted) {
142- this . #onLivenessCheckCompleted( ) ;
143- }
144- await displayStateCorruptionError (
145- this . #container,
146- this . #port,
147- error ,
148- hasBackup ,
149- currentLocale ,
150- ) ;
151- }
128+ await displayStateCorruptionError (
129+ this . #container,
130+ this . #port,
131+ error ,
132+ hasBackup ,
133+ currentLocale ,
134+ ) ;
152135 } else if ( method === DISPLAY_GENERAL_STARTUP_ERROR ) {
153136 if ( ! hasProperty ( data , 'params' ) || ! isObject ( data . params ) ) {
154137 log . error (
@@ -162,21 +145,12 @@ export class CriticalStartupErrorHandler {
162145 error : ErrorLike ;
163146 currentLocale ?: string ;
164147 } ;
165- // Only display error if we haven't already displayed one
166- if ( ! this . #errorDisplayed) {
167- this . #errorDisplayed = true ;
168- // Cancel the liveness check since we're displaying a general error
169- clearTimeout ( this . #livenessCheckTimeoutId) ;
170- if ( this . #onLivenessCheckCompleted) {
171- this . #onLivenessCheckCompleted( ) ;
172- }
173- await displayCriticalError (
174- this . #container,
175- CriticalErrorTranslationKey . TroubleStarting ,
176- error as ErrorLike ,
177- currentLocale ,
178- ) ;
179- }
148+ await displayCriticalError (
149+ this . #container,
150+ CriticalErrorTranslationKey . TroubleStarting ,
151+ error as ErrorLike ,
152+ currentLocale ,
153+ ) ;
180154 }
181155 } ;
182156
0 commit comments