Skip to content

Commit 5461e28

Browse files
committed
perform the healthCheck assignment after checking the stream state.
1 parent 7989d10 commit 5461e28

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/firestore/src/remote/persistent_stream.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,15 @@ export abstract class PersistentStream<
475475
this.stream = this.startRpc(token);
476476
this.stream.onOpen(() => {
477477
dispatchIfNotClosed(() => {
478-
debugAssert(this.healthCheck === null, 'Expected healthCheck to be null');
478+
debugAssert(
479+
this.state === PersistentStreamState.Starting,
480+
'Expected stream to be in state Starting, but was ' + this.state
481+
);
482+
this.state = PersistentStreamState.Open;
483+
debugAssert(
484+
this.healthCheck === null,
485+
'Expected healthCheck to be null'
486+
);
479487
this.healthCheck = this.queue.enqueueAfterDelay(
480488
this.healthTimerId,
481489
HEALTHY_TIMEOUT_MS,
@@ -486,11 +494,6 @@ export abstract class PersistentStream<
486494
return Promise.resolve();
487495
}
488496
);
489-
debugAssert(
490-
this.state === PersistentStreamState.Starting,
491-
'Expected stream to be in state Starting, but was ' + this.state
492-
);
493-
this.state = PersistentStreamState.Open;
494497
return this.listener!.onOpen();
495498
});
496499
});

0 commit comments

Comments
 (0)