@@ -142,19 +142,19 @@ export class RealtimeHandler {
142
142
* Stops the real-time HTTP connection by aborting the in-progress fetch request
143
143
* and canceling the stream reader if they exist.
144
144
*/
145
- private closeRealtimeHttpConnection ( ) : void {
146
- if ( this . isClosingConnection ) {
145
+ private async closeRealtimeHttpConnection ( ) : Promise < void > {
146
+ if ( this . isClosingConnection ) {
147
147
return ;
148
148
}
149
149
this . isClosingConnection = true ;
150
-
150
+
151
151
if ( this . reader ) {
152
- void this . reader . cancel ( ) ;
152
+ await this . reader . cancel ( ) ;
153
153
this . reader = undefined ;
154
154
}
155
155
156
156
if ( this . controller ) {
157
- this . controller . abort ( ) ;
157
+ await this . controller . abort ( ) ;
158
158
this . controller = undefined ;
159
159
}
160
160
@@ -595,8 +595,9 @@ export class RealtimeHandler {
595
595
this . setIsHttpConnectionRunning ( false ) ;
596
596
597
597
// Update backoff metadata if the connection failed in the foreground.
598
- const connectionFailed = ! this . isInBackground &&
599
- responseCode == null || this . isStatusCodeRetryable ( responseCode ) ;
598
+ const connectionFailed =
599
+ ! this . isInBackground &&
600
+ ( responseCode == null || this . isStatusCodeRetryable ( responseCode ) ) ;
600
601
601
602
if ( connectionFailed ) {
602
603
await this . updateBackoffMetadataWithLastFailedStreamConnectionTime (
@@ -682,7 +683,7 @@ export class RealtimeHandler {
682
683
private async onVisibilityChange ( visible : unknown ) : Promise < void > {
683
684
this . isInBackground = ! visible ;
684
685
if ( ! visible ) {
685
- await this . closeRealtimeHttpConnection ( ) ;
686
+ await this . closeRealtimeHttpConnection ( ) ;
686
687
} else if ( visible ) {
687
688
await this . beginRealtime ( ) ;
688
689
}
0 commit comments