@@ -41,7 +41,11 @@ export class RealtimeHandler {
4141 private readonly logger : Logger
4242 ) {
4343 void this . setRetriesRemaining ( ) ;
44- VisibilityMonitor . getInstance ( ) . on ( 'visible' , this . onVisibilityChange , this ) ;
44+ void VisibilityMonitor . getInstance ( ) . on (
45+ 'visible' ,
46+ this . onVisibilityChange ,
47+ this
48+ ) ;
4549 }
4650
4751 private observers : Set < ConfigUpdateObserver > =
@@ -106,8 +110,8 @@ export class RealtimeHandler {
106110 */
107111 private closeRealtimeHttpConnection ( ) : void {
108112 if ( this . controller && ! this . isInBackground ) {
109- this . controller . abort ( ) ;
110- this . controller = undefined ;
113+ this . controller . abort ( ) ;
114+ this . controller = undefined ;
111115 }
112116
113117 if ( this . reader ) {
@@ -269,11 +273,11 @@ export class RealtimeHandler {
269273 // this as a success, even if we haven't read a 200 response code yet.
270274 this . resetRetryCount ( ) ;
271275 } else {
272- //there might have been a transient error so the client will retry the connection.
273- this . logger . error (
274- 'Exception connecting to real-time RC backend. Retrying the connection...:' ,
275- error
276- ) ;
276+ //there might have been a transient error so the client will retry the connection.
277+ this . logger . debug (
278+ 'Exception connecting to real-time RC backend. Retrying the connection...:' ,
279+ error
280+ ) ;
277281 }
278282 } finally {
279283 // Close HTTP connection and associated streams.
@@ -315,9 +319,14 @@ export class RealtimeHandler {
315319 const isNotDisabled = ! this . isRealtimeDisabled ;
316320 const isNoConnectionActive = ! this . isConnectionActive ;
317321 const inForeground = ! this . isInBackground ;
318- return hasActiveListeners && isNotDisabled && isNoConnectionActive && inForeground ;
322+ return (
323+ hasActiveListeners &&
324+ isNotDisabled &&
325+ isNoConnectionActive &&
326+ inForeground
327+ ) ;
319328 }
320-
329+
321330 private async makeRealtimeHttpConnection ( delayMillis : number ) : Promise < void > {
322331 if ( ! this . canEstablishStreamConnection ( ) ) {
323332 return ;
@@ -328,7 +337,10 @@ export class RealtimeHandler {
328337 await this . beginRealtimeHttpStream ( ) ;
329338 } , delayMillis ) ;
330339 } else if ( ! this . isInBackground ) {
331- const error = ERROR_FACTORY . create ( ErrorCode . CONFIG_UPDATE_STREAM_ERROR , { originalErrorMessage : 'Unable to connect to the server. Check your connection and try again.' } ) ;
340+ const error = ERROR_FACTORY . create ( ErrorCode . CONFIG_UPDATE_STREAM_ERROR , {
341+ originalErrorMessage :
342+ 'Unable to connect to the server. Check your connection and try again.'
343+ } ) ;
332344 this . propagateError ( error ) ;
333345 }
334346 }
@@ -358,12 +370,12 @@ export class RealtimeHandler {
358370 }
359371 }
360372
361- private async onVisibilityChange ( visible : unknown ) {
373+ private async onVisibilityChange ( visible : unknown ) : Promise < void > {
362374 this . isInBackground = ! visible ;
363375 if ( ! visible && this . controller ) {
364376 this . controller . abort ( ) ;
365377 this . controller = undefined ;
366- } else if ( visible ) {
378+ } else if ( visible ) {
367379 await this . beginRealtime ( ) ;
368380 }
369381 }
0 commit comments