There is an issue where SynchronizationDataService requests a snapshot for an object from destinationDataService before the snapshot has been recorded. Note that this issue is intermittent and non-deterministic. It may not happen for all objects and it may not happen every time.
The expected flow of data
originDataService dispatches a ReadCompletedOperation
SynchronizationDataService captures ReadCompletedOperation
SynchronizationDataService attempts to sync the operation data to the destinationDataService.
- Register objects as "tracked" so that any changes to those objects are synced
- Map objects from rawData.
- This triggers change events on the objects
- Because the objects are "tracked", the changes are added to a Transaction
destinationDataService passes the Transaction to the worker
- When transaction completes, we record a snapshot of the object
- SynchronizationDataService
explicitly callsmainService.saveChanges()` which should wait for the transaction created in step 3->ii->b to complete. Meaning the object's snapshot has been recorded.
- Retrieve the snapshot from the
destinationDataService
The issue is that occasionally mainService.saveChanges() (in step 4) resolves before the Transaction created in step 3->ii->b is complete and the snapshot is therefore not available. This is currently worked around by explicitly waiting for pending transaction promises using DataService.pendingTransactionPromiseForObjects: https://github.com/PhrontHQ/mod/blob/main/data/service/mux/synchronization-data-service.js#L1237
The goal of this ticket is to determine how mainService.saveChanges() can resolve before the existing pending transactions have completed.