Hello,
I'm investigating an issue we're facing intermittently during sync operations after updated to the latest 5.6.x (from 5.5.x), basically on larger schedules during a sync operation we intermittently get the error:
Cannot set properties of null (setting 'readOnly')
I've traced the source to the Model.js get modificationDataToWrite() method, which looks like this:
get modificationDataToWrite() {
const
alwaysWriteFields = this.constructor.alwaysWriteFields,
recordData = this.modificationData;
alwaysWriteFields.forEach(fieldName => {
recordData[this.getFieldDefinition(fieldName).dataSource] = this.getFieldPersistentValue(fieldName);
});
return recordData;
}
The cause is that recordData is sometimes null. (The readOnly prop is just be the first of the fields that is passed from this.allFields...)
That error seems inevitable as the method references modificationData (from rawModificationData()) which does return null, e.g.:
get rawModificationData() {
const
me = this,
{ fieldMap } = me.constructor,
data = {};
if (!me.isModified) {
return null;
}
...
My workaround is to override the above modificationDataToWrite method in my class but either this seems like a bug as it clearly can be null, however this code doesn't appear to have changed between 5.5.5 -> 5.6.7 (what I've tested). What could be causing that?
We don't use alwaysWrite on any of our model fields (anymore) and so I'm not sure why readOnly and other model props are being passed in to this method from alwaysWriteFields.
Thanks,