Premium support for our pure JavaScript UI components


Post by mlaukkanen »

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,


Post by marcio »

Hey mlaukkanen,

Thanks for reaching out and for the detailed report.

Are you able to reproduce that on one of our demos? Would it be possible for you to share a sample project with that error that you mentioned, perhaps adapt one of our demos with your configuration plus some data samples?

With that, it would be easier and faster to debug and find what's causing that null error.

Best regards,
Márcio


Post by mlaukkanen »

I've done some more research in my implementation and I can see that the problem seems to be on the Project Model only, previously we implemented a "force sync all" function which basically loops though all stores and temporarily sets alwaysWriteFields to include all persistent fields (it first pauses auto sync, then does a manual sync before cleaning up). In some cases when that runs against the Project Model this occurs.

I'll look and see if I can extract our "force sync" method and add it to a example but I suspect it won't happen as the json example data doesn't have any project level fields that can change other than start date.


Post by ghulam.ghous »

Hi @mlaukkanen,

We cannot say what is wrong without looking at a test case. You can use our advanced example where we have two custom fields on the taskModel class status and complexity which are editable in the columns. Probably you can edit them and apply forceSync method and see if the problem occurs.

Regards,
Ghous


Post Reply