Hi there.
The following code crashes on the third change with:
let d = Automerge.init();
d = Automerge.emptyChange(d);
d = Automerge.change(d, (doc) => (doc.z = 1));
d = Automerge.change(d, (doc) => (doc.z = 1000));
The full trace is:
encoding.js:153 Uncaught RangeError: value is not an integer
at DeltaEncoder.appendInt53 (encoding.js:153)
at DeltaEncoder.appendRawValue (encoding.js:764)
at DeltaEncoder.flush (encoding.js:751)
at DeltaEncoder._appendValue (encoding.js:627)
at DeltaEncoder.appendValue (encoding.js:573)
at DeltaEncoder.appendValue (encoding.js:945)
at appendOperation (new.js:636)
at appendChange (new.js:1676)
at BackendDoc.applyChanges (new.js:1841)
at Object.applyLocalChange (backend.js:84)
I can tell from my debugging:
The first change contains no ops.
In applyLocalChange, the change has no maxOp field. The change is encoded in applyLocalChange and decoded in applyChanges. After decoding, maxOp is still undefined.
appendChange extracts the maxOp field of the change, which is undefined.
This undefined maxOp is encoded into the maxOp column.
For some reason the second change does not crash.
In the third change, DeltaEncoder accesses the first maxOp value (which is undefined) to compute the difference of the current value. This crashes with the above error.
Hi there. The following code crashes on the third change with:
The full trace is:
I can tell from my debugging:
applyLocalChange
, the change has nomaxOp
field. The change is encoded inapplyLocalChange
and decoded inapplyChanges
. After decoding,maxOp
is still undefined.appendChange
extracts themaxOp
field of the change, which is undefined.maxOp
is encoded into themaxOp
column.DeltaEncoder
accesses the firstmaxOp
value (which is undefined) to compute the difference of the current value. This crashes with the above error.I hope these breadcrumbs are helpful.