Skip to content

Commit 658f452

Browse files
Making keepInQueue optional
1 parent d798ed0 commit 658f452

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

packages/firestore/test/unit/specs/spec_builder.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ import {
4646
SpecQueryFilter,
4747
SpecQueryOrderBy,
4848
SpecStep,
49-
SpecWatchFilter
49+
SpecWatchFilter,
50+
SpecWriteAck,
51+
SpecWriteFailure
5052
} from './spec_test_runner';
5153
import { TimerId } from '../../../src/util/async_queue';
5254

@@ -474,9 +476,11 @@ export class SpecBuilder {
474476
this.nextStep();
475477
options = options || {};
476478

477-
this.currentStep = {
478-
writeAck: { version, keepInQueue: !!options.keepInQueue }
479-
};
479+
const writeAck: SpecWriteAck = { version };
480+
if (options.keepInQueue) {
481+
writeAck.keepInQueue = true;
482+
}
483+
this.currentStep = { writeAck };
480484

481485
if (options.expectUserCallback !== false) {
482486
return this.expectUserCallbacks({ acknowledged: [doc] });
@@ -506,7 +510,11 @@ export class SpecBuilder {
506510
? options.keepInQueue
507511
: !isPermanentFailure;
508512

509-
this.currentStep = { failWrite: { error, keepInQueue } };
513+
const failWrite: SpecWriteFailure = { error };
514+
if (keepInQueue) {
515+
failWrite.keepInQueue = true;
516+
}
517+
this.currentStep = { failWrite };
510518

511519
if (options.expectUserCallback !== false) {
512520
return this.expectUserCallbacks({ rejected: [doc] });

packages/firestore/test/unit/specs/spec_test_runner.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1393,9 +1393,11 @@ export type SpecWriteAck = {
13931393
* Whether we should keep the write in our internal queue. This should only
13941394
* be set to 'true' if the client ignores the write (e.g. a secondary client
13951395
* which ignores write acknowledgments).
1396+
*
1397+
* Defaults to false.
13961398
*/
13971399
// PORTING NOTE: Multi-Tab only.
1398-
keepInQueue: boolean;
1400+
keepInQueue?: boolean;
13991401
};
14001402

14011403
export type SpecWriteFailure = {
@@ -1405,8 +1407,10 @@ export type SpecWriteFailure = {
14051407
* Whether we should keep the write in our internal queue. This should be set
14061408
* to 'true' for transient errors or if the client ignores the failure
14071409
* (e.g. a secondary client which ignores write rejections).
1410+
*
1411+
* Defaults to false.
14081412
*/
1409-
keepInQueue: boolean;
1413+
keepInQueue?: boolean;
14101414
};
14111415

14121416
export interface SpecWatchEntity {

0 commit comments

Comments
 (0)