In the SyncNodeData method of the DataSyncService the following code is not correct:
// account for removed node data
if (changes.removedNodeKeys) {
const removals = changes.removedNodeKeys.map(key => keyIdxMap.get(key)).sort();
for (let i = removals.length - 1; i >= 0; i--) {
draft.splice(removals[i], 1);
}
}
Specifically the sort() function of javascript is sorting the array of indices as strings. This is the default behavior if no sort function is provided. If you try deleting multiple nodes with indices of different orders of magnitude (for example [10, 11, 7]) a semi-random node will be deleted instead. The correct version of the code would look like this:
// account for removed node data
if (changes.removedNodeKeys) {
const removals = (changes.removedNodeKeys.map((key) => keyIdxMap.get(key)) as number[]).sort(
(a, b) => a - b
);
for (let i = removals.length - 1; i >= 0; i--) {
draft.splice(removals[i], 1);
}
}
The SyncLinkData method behaves analogously.