@@ -94,7 +94,7 @@ export class CollectionSyncManager<
9494 }
9595 const key = this . config . getKey ( messageWithoutKey . value )
9696
97- let messageType = messageWithoutKey . type
97+ let messageType = messageWithoutKey . type
9898
9999 // Check if an item with this key already exists when inserting
100100 if ( messageWithoutKey . type === `insert` ) {
@@ -108,25 +108,25 @@ export class CollectionSyncManager<
108108 ! hasPendingDeleteForKey &&
109109 ! isTruncateTransaction
110110 ) {
111- const existingValue = state . syncedData . get ( key )
112- if (
113- existingValue !== undefined &&
114- deepEquals ( existingValue , messageWithoutKey . value )
115- ) {
116- // The "insert" is an echo of a value we already have locally.
117- // Treat it as an update so we preserve optimistic intent without
118- // throwing a duplicate-key error during reconciliation.
119- messageType = `update`
120- } else {
121- throw new DuplicateKeySyncError ( key , this . id )
111+ const existingValue = this . state . syncedData . get ( key )
112+ if (
113+ existingValue !== undefined &&
114+ deepEquals ( existingValue , messageWithoutKey . value )
115+ ) {
116+ // The "insert" is an echo of a value we already have locally.
117+ // Treat it as an update so we preserve optimistic intent without
118+ // throwing a duplicate-key error during reconciliation.
119+ messageType = `update`
120+ } else {
121+ throw new DuplicateKeySyncError ( key , this . id )
122122 }
123- }
123+ }
124124 }
125125
126126 const message : ChangeMessage < TOutput > = {
127127 ...messageWithoutKey ,
128128 type : messageType ,
129- key,
129+ key,
130130 }
131131 pendingTransaction . operations . push ( message )
132132
0 commit comments