@@ -410,10 +410,11 @@ function applySetMutationToLocalView(
410
410
document : MutableDocument ,
411
411
localWriteTime : Timestamp
412
412
) : void {
413
- debugAssert (
414
- mutation . precondition . isNone ,
415
- 'SetMutations should not have preconditions outside of Transactions'
416
- ) ;
413
+ if ( ! preconditionIsValidForDocument ( mutation . precondition , document ) ) {
414
+ // The mutation failed to apply (e.g. a document ID created with add()
415
+ // caused a name collision).
416
+ return ;
417
+ }
417
418
418
419
const newData = mutation . value . clone ( ) ;
419
420
const transformResults = localTransformResults (
@@ -626,14 +627,11 @@ function applyDeleteMutationToLocalView(
626
627
document . key . isEqual ( mutation . key ) ,
627
628
'Can only apply mutation to document with same key'
628
629
) ;
629
- debugAssert (
630
- mutation . precondition . isNone ,
631
- 'DeleteMutions should not have preconditions outside of Transactions'
632
- ) ;
633
-
634
- // We don't call `setHasLocalMutations()` since we want to be backwards
635
- // compatible with the existing SDK behavior.
636
- document . convertToNoDocument ( SnapshotVersion . min ( ) ) ;
630
+ if ( preconditionIsValidForDocument ( mutation . precondition , document ) ) {
631
+ // We don't call `setHasLocalMutations()` since we want to be backwards
632
+ // compatible with the existing SDK behavior.
633
+ document . convertToNoDocument ( SnapshotVersion . min ( ) ) ;
634
+ }
637
635
}
638
636
639
637
/**
0 commit comments