Skip to content

Commit 7989d10

Browse files
committed
Perform everything in dispatchIfNotClosed.
1 parent e1ce005 commit 7989d10

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

packages/firestore/src/remote/persistent_stream.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -475,15 +475,7 @@ export abstract class PersistentStream<
475475
this.stream = this.startRpc(token);
476476
this.stream.onOpen(() => {
477477
dispatchIfNotClosed(() => {
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-
return this.listener!.onOpen();
484-
});
485-
486-
if (this.healthCheck === null) {
478+
debugAssert(this.healthCheck === null, 'Expected healthCheck to be null');
487479
this.healthCheck = this.queue.enqueueAfterDelay(
488480
this.healthTimerId,
489481
HEALTHY_TIMEOUT_MS,
@@ -494,7 +486,13 @@ export abstract class PersistentStream<
494486
return Promise.resolve();
495487
}
496488
);
497-
}
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;
494+
return this.listener!.onOpen();
495+
});
498496
});
499497
this.stream.onClose((error?: FirestoreError) => {
500498
dispatchIfNotClosed(() => {

0 commit comments

Comments
 (0)