Skip to content

Commit 748f2cc

Browse files
Modify in tandem with handshakeComplete
1 parent b530cd5 commit 748f2cc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/firestore/src/remote/persistent_stream.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,13 @@ export class PersistentWriteStream extends PersistentStream<
682682
// Override of PersistentStream.start
683683
start(): void {
684684
this.handshakeComplete_ = false;
685+
this.lastStreamToken = ByteString.EMPTY_BYTE_STRING;
685686
super.start();
686687
}
687688

688689
protected tearDown(): void {
689690
if (this.handshakeComplete_) {
690691
this.writeMutations([]);
691-
this.lastStreamToken = ByteString.EMPTY_BYTE_STRING;
692692
}
693693
}
694694

@@ -742,6 +742,10 @@ export class PersistentWriteStream extends PersistentStream<
742742
writeHandshake(): void {
743743
debugAssert(this.isOpen(), 'Writing handshake requires an opened stream');
744744
debugAssert(!this.handshakeComplete_, 'Handshake already completed');
745+
debugAssert(
746+
this.lastStreamToken.isEqual(ByteString.EMPTY_BYTE_STRING),
747+
'Stream token should be empty during handshake'
748+
);
745749
// TODO(dimond): Support stream resumption. We intentionally do not set the
746750
// stream token on the handshake, ignoring any stream token we might have.
747751
const request: WriteRequest = {};

0 commit comments

Comments
 (0)