Skip to content

Commit 9b1c7bb

Browse files
Addressing comments & fixing build
1 parent a8a7d76 commit 9b1c7bb

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

packages/firestore/src/api/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ export class Firestore implements firestore.Firestore, FirebaseService {
456456
}
457457
}
458458

459-
/** Creates a new AsyncQueue. Can be overwritten to provide a custom queue. */
459+
/** Creates a new AsyncQueue. Can be overridden to provide a custom queue. */
460460
protected initializeAsyncQueue(): AsyncQueue {
461461
return new AsyncQueue();
462462
}

packages/firestore/src/remote/persistent_stream.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ export abstract class PersistentStream<
255255
return this.handleIdleCloseTimer();
256256
}, IDLE_TIMEOUT_MS)
257257
.catch((err: FirestoreError) => {
258-
// We ignore Promise rejections for cancelled idle checks.
258+
// When the AsyncQueue gets drained during a shutdown, pending Promises
259+
// (including these idle checks) will get rejected. We special-case
260+
// these cancelled idle checks to make sure that these specific Promise
261+
// rejections are not considered unhandled.
259262
assert(
260263
err.code === Code.CANCELLED,
261264
`Received unexpected error in idle timeout closure. Expected CANCELLED, but was: ${err}`
@@ -287,12 +290,10 @@ export abstract class PersistentStream<
287290
/**
288291
* Closes the stream and cleans up as necessary:
289292
*
290-
* <ul>
291-
* <li>closes the underlying GRPC stream;
292-
* <li>calls the onClose handler with the given 'error';
293-
* <li>sets internal stream state to 'finalState';
294-
* <li>adjusts the backoff timer based on the error
295-
* </ul>
293+
* * closes the underlying GRPC stream;
294+
* * calls the onClose handler with the given 'error';
295+
* * sets internal stream state to 'finalState';
296+
* * adjusts the backoff timer based on the error
296297
*
297298
* A new stream can be opened by calling `start` unless `finalState` is set to
298299
* `PersistentStreamState.Stopped`.

packages/firestore/src/util/async_queue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class AsyncQueue {
5050

5151
if ((delay || 0) > 0) {
5252
const deferred = new Deferred<T>();
53-
let handle = window.setTimeout(() => {
53+
const handle = window.setTimeout(() => {
5454
this.scheduleInternal(() => {
5555
return op().then(result => {
5656
deferred.resolve(result);
@@ -103,7 +103,7 @@ export class AsyncQueue {
103103
this.delayedOperations.forEach((deferred, handle) => {
104104
window.clearTimeout(handle);
105105
deferred.reject(
106-
new FirestoreError(Code.CANCELLED, 'Cancelled during queue drain')
106+
new FirestoreError(Code.CANCELLED, 'Operation cancelled by shutdown')
107107
);
108108
});
109109
this.delayedOperations.clear();

packages/firestore/test/integration/util/helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import * as firestore from 'firestore';
1818

19+
import { FirebaseApp } from '@firebase/app';
20+
1921
import { DatabaseId, DatabaseInfo } from '../../../src/core/database_info';
2022
import { Datastore } from '../../../src/remote/datastore';
2123

@@ -24,7 +26,6 @@ import { EmptyCredentialsProvider } from '../../../src/api/credentials';
2426
import { PlatformSupport } from '../../../src/platform/platform';
2527
import { AsyncQueue } from '../../../src/util/async_queue';
2628
import { Firestore, FirestoreDatabase } from '../../../src/api/database';
27-
import { FirebaseApp } from '../../../../app/index';
2829
import { TestQueue } from './test_queue';
2930

3031
// tslint:disable-next-line:no-any __karma__ is an untyped global

0 commit comments

Comments
 (0)