Inconsistent value in HistoricalModel.time()


#1

First of all, I am assuming that the time() method returns the time at which the current (played back to) version of a HistoricalModel was created.

I have a piece of code that iterates through an array of “snapshots”, where each snapshot tracks the model version at which it was created:

// iterate through them in descending chronological order
for(let i = historicalSnapshots.length - 1; i >= 0; i--) {
  let snapshotMetadata = historicalSnapshots[i];
  let historicalFragment = new HistoricalFragment(historicalModel, snapshotMetadata);

  // defined below
  await historicalFragment.playTo(snapshotMetadata.version);
  // push the historical model corresponding to the version in the metadata
  snapshots.push(historicalFragment);
  console.log('fragment', historicalFragment.id, 'version', historicalFragment.version, 'time', historicalFragment.at);
}

public async playTo(desiredVersion:number):Promise<void> {
  this._version = desiredVersion;
  // "play" back to the desired version
  await this._model.playTo(this._version);
  ...
}

Here is what is printed initially:

fragment dOsR7Gs98RliPamw version 140 time Wed Apr 24 2019 11:35:26 GMT-0600 (Mountain Daylight Time)
fragment dOsR7Gs98RliPamw version 139 time Wed Apr 24 2019 11:35:26 GMT-0600 (Mountain Daylight Time)
fragment dOsR7Gs98RliPamw version 70 time Wed Apr 24 2019 11:21:44 GMT-0600 (Mountain fragment dOsR7Gs98RliPamw version 3 time Wed Feb 27 2019 01:52:15 GMT-0700 (Mountain Standard Time)
fragment dOsR7Gs98RliPamw version 2 time Wed Feb 27 2019 01:44:52 GMT-0700 (Mountain Standard Time)

Then, I make a few changes, and execute the method again:

fragment dOsR7Gs98RliPamw version 183 time Wed Apr 24 2019 11:47:53 GMT-0600 (Mountain Daylight Time)
fragment dOsR7Gs98RliPamw version 140 time Wed Apr 24 2019 11:47:46 GMT-0600 (Mountain Daylight Time)
fragment dOsR7Gs98RliPamw version 139 time Wed Apr 24 2019 11:35:26 GMT-0600 (Mountain Daylight Time)
fragment dOsR7Gs98RliPamw version 70 time Wed Apr 24 2019 11:21:44 GMT-0600 (Mountain Daylight Time)
fragment dOsR7Gs98RliPamw version 3 time Wed Feb 27 2019 01:52:15 GMT-0700 (Mountain Standard Time)
fragment dOsR7Gs98RliPamw version 2 time Wed Feb 27 2019 01:44:52 GMT-0700 (Mountain Standard Time)

It seems that the second-to-last snapshot’s time is indeterminate. Notice how the time corresponding with version 140 changes. Could be some sort of race condition?


#2

Thanks for reporting. Looks like there is a small issue here. We will attempt to replicate the issue and get back to you shortly.


#3

A few questions.

  1. It appears that you are playing through the versions backwards, meaning from most recent to least recent. Is this correct? If you play them in ascending order, does the issue still occur?
  2. When you call this method, what would the original versions of the models have been. Meaning did the model start out at version 140 and then 183 respectively? Or would they have been at some other version?

#4

Interesting. Indeed, the problem seems to be resolved when I play through the versions forwards. The original versions were 140/183, yes.


#5

Thanks. I believe that confirms our understanding of the issue. This should be a simple fix, and will be released in 1.0.0-rc.3 which should be released in the next several days.