Skip to content

Commit a8a7d76

Browse files
Comment fixes
1 parent 8ad4df2 commit a8a7d76

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

packages/firestore/src/remote/persistent_stream.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ export abstract class PersistentStream<
224224
* When stop returns, isStarted and isOpen will both return false.
225225
*/
226226
stop(): void {
227-
this.close(PersistentStreamState.Stopped);
227+
if (this.isStarted()) {
228+
this.close(PersistentStreamState.Stopped);
229+
}
228230
}
229231

230232
/**
@@ -256,7 +258,7 @@ export abstract class PersistentStream<
256258
// We ignore Promise rejections for cancelled idle checks.
257259
assert(
258260
err.code === Code.CANCELLED,
259-
'Received unexpected error in idle timeout closure.'
261+
`Received unexpected error in idle timeout closure. Expected CANCELLED, but was: ${err}`
260262
);
261263
});
262264
}
@@ -293,7 +295,7 @@ export abstract class PersistentStream<
293295
* </ul>
294296
*
295297
* A new stream can be opened by calling `start` unless `finalState` is set to
296-
* `PersistentStreamState.Stoppen`.
298+
* `PersistentStreamState.Stopped`.
297299
*
298300
* @param finalState the intended state of the stream after closing.
299301
* @param error the error the connection was closed with.
@@ -324,17 +326,15 @@ export abstract class PersistentStream<
324326
// inhibit backoff or otherwise manipulate the state in its non-started state.
325327
this.state = finalState;
326328

327-
// Clean up the underlying stream because we are no longer interested in
328-
// events
329+
// Clean up the underlying stream because we are no longer interested in events.
329330
if (this.stream !== null) {
330331
this.stream.close();
331332
this.stream = null;
332333
}
333334

334335
const listener = this.listener!;
335336

336-
// Clear the listener to avoid bleeding of events from the underlying
337-
// streams
337+
// Clear the listener to avoid bleeding of events from the underlying streams.
338338
this.listener = null;
339339

340340
// If the caller explicitly requested a stream stop, don't notify them of a closing stream (it

packages/firestore/src/remote/remote_store.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,9 @@ export class RemoteStore {
708708
'onWriteStreamClose() should only be called when the network is enabled'
709709
);
710710

711-
// Ignore close if there are no pending writes.
712-
if (this.pendingWrites.length > 0) {
711+
// If the write stream closed due to an error, invoke the error callbacks if there are pending
712+
// writes.
713+
if (error && this.pendingWrites.length > 0) {
713714
assert(
714715
!!error,
715716
'We have pending writes, but the write stream closed without an error'

packages/firestore/src/util/async_queue.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export class AsyncQueue {
2424
// The last promise in the queue.
2525
private tail: Promise<AnyJs | void> = Promise.resolve();
2626

27-
// A map of timeout handles to the respective deferred promises. Contains an
28-
// entry for each operation that is still queued to be run in the future
29-
// (i.e. it has a delay that has not yet elapsed).
27+
// A map of timeout handles to their respective deferred promises. Contains an
28+
// entry for each operation that is still queued to run in the future (i.e. it
29+
// has a delay that has not yet elapsed).
3030
private delayedOperations: Map<number, Deferred<any>> = new Map();
3131

3232
// visible for testing

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ const IDLE_DISPATCH_DELAY_MS = 60.0 * 1000;
2222
/** The maximum delay we use in a test run. */
2323
const TEST_DISPATCH_DELAY_MS = 1.0 * 1000;
2424

25+
/**
26+
* Dispatch queue used in the integration tests that caps delayed executions at
27+
* 1.0 seconds.
28+
*/
2529
export class TestQueue extends AsyncQueue {
2630
idleTimeoutDeferred: Deferred<void> | null = null;
2731

0 commit comments

Comments
 (0)