Skip to content

Bug Fix: (SynchronizationDataService / WebSocketDataOperationService) Fix issue where object syncing promise returns before object transactions are saved. #114

@tejaede

Description

@tejaede

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

  1. originDataService dispatches a ReadCompletedOperation
  2. SynchronizationDataService captures ReadCompletedOperation
  3. SynchronizationDataService attempts to sync the operation data to the destinationDataService.
    1. Register objects as "tracked" so that any changes to those objects are synced
    2. Map objects from rawData.
      1. This triggers change events on the objects
      2. Because the objects are "tracked", the changes are added to a Transaction
      3. destinationDataService passes the Transaction to the worker
      4. When transaction completes, we record a snapshot of the object
  4. SynchronizationDataServiceexplicitly callsmainService.saveChanges()` which should wait for the transaction created in step 3->ii->b to complete. Meaning the object's snapshot has been recorded.
  5. 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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions