@@ -73,8 +73,10 @@ export class Firestore implements FirestoreService {
73
73
private _settingsFrozen = false ;
74
74
75
75
// 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' ;
78
80
79
81
/** @hideconstructor */
80
82
constructor (
@@ -104,7 +106,7 @@ export class Firestore implements FirestoreService {
104
106
}
105
107
106
108
get _terminated ( ) : boolean {
107
- return this . _terminateTask !== undefined ;
109
+ return this . _terminateTask !== 'notTerminated' ;
108
110
}
109
111
110
112
_setSettings ( settings : PrivateSettings ) : void {
@@ -132,17 +134,17 @@ export class Firestore implements FirestoreService {
132
134
}
133
135
134
136
_delete ( ) : Promise < void > {
135
- if ( ! this . _terminateTask ) {
137
+ if ( this . _terminateTask === 'notTerminated' ) {
136
138
this . _terminateTask = this . _terminate ( ) ;
137
139
}
138
140
return this . _terminateTask ;
139
141
}
140
142
141
143
async _restart ( ) : Promise < void > {
142
- if ( this . _terminateTask ) {
143
- this . _terminateTask = undefined ;
144
- } else {
144
+ if ( this . _terminateTask === 'notTerminated' ) {
145
145
await this . _terminate ( ) ;
146
+ } else {
147
+ this . _terminateTask = 'notTerminated' ;
146
148
}
147
149
}
148
150
0 commit comments