Skip to content

Commit 9605531

Browse files
committed
Apply suggestions from Andy
1 parent af72d73 commit 9605531

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

packages/firestore/src/lite-api/database.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ export class Firestore implements FirestoreService {
7373
private _settingsFrozen = false;
7474

7575
// A task that is assigned when the terminate() is invoked and resolved when
76-
// all components have shut down.
77-
private _terminateTask?: Promise<void>;
76+
// all components have shut down. Otherwise, Firestore is not terminated,
77+
// which can mean either the FirestoreClient is in the process of starting,
78+
// or restarting.
79+
private _terminateTask: Promise<void> | 'notTerminated' = 'notTerminated';
7880

7981
/** @hideconstructor */
8082
constructor(
@@ -104,7 +106,7 @@ export class Firestore implements FirestoreService {
104106
}
105107

106108
get _terminated(): boolean {
107-
return this._terminateTask !== undefined;
109+
return this._terminateTask !== 'notTerminated';
108110
}
109111

110112
_setSettings(settings: PrivateSettings): void {
@@ -132,17 +134,17 @@ export class Firestore implements FirestoreService {
132134
}
133135

134136
_delete(): Promise<void> {
135-
if (!this._terminateTask) {
137+
if (this._terminateTask === 'notTerminated') {
136138
this._terminateTask = this._terminate();
137139
}
138140
return this._terminateTask;
139141
}
140142

141143
async _restart(): Promise<void> {
142-
if (this._terminateTask) {
143-
this._terminateTask = undefined;
144-
} else {
144+
if (this._terminateTask === 'notTerminated') {
145145
await this._terminate();
146+
} else {
147+
this._terminateTask = 'notTerminated';
146148
}
147149
}
148150

0 commit comments

Comments
 (0)