@@ -137,6 +137,19 @@ export class FirestoreClient {
137
137
) ;
138
138
}
139
139
140
+ /**
141
+ * Checks that the client has not been terminated. Ensures that other methods on
142
+ * this class cannot be called after the client is terminated.
143
+ */
144
+ verifyNotTerminated ( ) : void {
145
+ if ( this . asyncQueue . isShuttingDown ) {
146
+ throw new FirestoreError (
147
+ Code . FAILED_PRECONDITION ,
148
+ 'The client has already been terminated.'
149
+ ) ;
150
+ }
151
+ }
152
+
140
153
terminate ( ) : Promise < void > {
141
154
this . asyncQueue . enterRestrictedMode ( ) ;
142
155
const deferred = new Deferred ( ) ;
@@ -169,6 +182,8 @@ export class FirestoreClient {
169
182
async function ensureOfflineComponents (
170
183
firestoreClient : FirestoreClient
171
184
) : Promise < OfflineComponentProvider > {
185
+ firestoreClient . verifyNotTerminated ( ) ;
186
+
172
187
if ( ! firestoreClient . offlineComponents ) {
173
188
logDebug ( LOG_TAG , 'Using default OfflineComponentProvider' ) ;
174
189
await setOfflineComponentProvider (
@@ -183,6 +198,8 @@ async function ensureOfflineComponents(
183
198
async function ensureOnlineComponents (
184
199
firestoreClient : FirestoreClient
185
200
) : Promise < OnlineComponentProvider > {
201
+ firestoreClient . verifyNotTerminated ( ) ;
202
+
186
203
if ( ! firestoreClient . onlineComponents ) {
187
204
logDebug ( LOG_TAG , 'Using default OnlineComponentProvider' ) ;
188
205
await setOnlineComponentProvider (
0 commit comments