The constructor performs a call to an async function and assigns the callback handler to the array, which is suppose to be populated with the "op" object and not the callback function itself.
generateOperation is an async method, but it's called in constructor (which can't be async):
constructor(options = { }) {
this.#ops = options.ops || [ ];
this.#generateKeyPair = options.generateKeyPair || generateKeyPair;
if (!this.#ops.length) {
this.#ops.push(this.generateOperation('create', options.content || { }, false));
}
}
Since it's a callback reference and not the actual operation data, the previous field on second operation becomes a ZoneAwarePromise instead of the operation data.
previous: ZoneAwarePromise
This results in serialization of the state not being correct.
This can probably only be solved by removing this default create operation and requiring the library consumer to call some "create" method instead.
The constructor performs a call to an async function and assigns the callback handler to the array, which is suppose to be populated with the "op" object and not the callback function itself.
generateOperationis an async method, but it's called in constructor (which can't be async):Since it's a callback reference and not the actual operation data, the
previousfield on second operation becomes aZoneAwarePromiseinstead of the operation data.previous: ZoneAwarePromiseThis results in serialization of the state not being correct.
This can probably only be solved by removing this default create operation and requiring the library consumer to call some "create" method instead.