derbyjs / racer

Realtime model synchronization engine for Node.js
1.18k stars 116 forks source link

fix error where shareDoc.version can be null #272

Closed eveshum closed 4 years ago

eveshum commented 4 years ago

If shareDoc.version is null, then we can get a ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION error

ericyhwang commented 4 years ago

I just added a test for this case!

For reference, the test without this change fails like this:

Uncaught ShareDBError: Missing version in ingested snapshot. dogs.fido
  at Doc.ingestSnapshot (node_modules/sharedb/lib/client/doc.js:163:15)
  at new RemoteDoc (lib/Model/RemoteDoc.js:28:17)
  at Collection.add (lib/Model/collections.js:115:13)
  at Model.getOrCreateDoc (lib/Model/collections.js:69:44)
  at Model.unbundle (lib/Model/unbundle.js:13:12)
  at test/Model/bundle.js:27:18
  at finishBundle (lib/Model/bundle.js:35:5)
  at process._tickCallback (internal/process/next_tick.js:61:11)