Our powerful JS Calendar component


Post by isilogplanning »

Hello,

I’m using Bryntum Calendar thin 7.2.2 together with a SchedulerPro ProjectModel (engine) and a custom event model that extends SchedulerPro EventModel). When an event has preamble / postamble and I navigate far in time and back (triggering engine recalculation/commit), I get this runtime error :

Uncaught (in promise) TypeError: Cannot set property wrapEndDate of [object Object] which has only a getter
    at ModelClass.endBatch (EventModel.js:983:26)
    at EngineReplica.finalizeCommitAsync (Replica.js:241:22)
    at async EngineReplica.doCommitAsync (Graph.js:320:5)
    at async IsiProject.internalDelayCalculation (SchedulerBasicProjectMixin.js:431:22)

Findings / root cause
It seems to be caused by a conflict between SchedulerPro EventModel and Calendar feature EventBuffer:
SchedulerPro EventModel.endBatch() invalidates the cached wrap dates when postamble is present:

// @bryntum/schedulerpro-thin/lib/model/EventModel.js
if (batchChanges) {
  if ('endDate' in batchChanges) {
    delete me._endDate;
    if (me.postamble) {
      me.wrapEndDate = null; // <-- crashes
    }
  }
}

Calendar EventBuffer feature defines wrapStartDate, wrapEndDate, outerStartDate, outerEndDate as getter-only properties on the event model prototype:

// @bryntum/calendar-thin/lib/feature/EventBuffer.js
const wrapFieldDefinitions = {
  wrapEndDate : { get() { return DateHelper.add(this.endDate, Duration.from(this.postamble)); } },
  // ...
};
if (!Object.getOwnPropertyDescriptor(eventRecord.constructor.prototype, 'wrapStartDate')) {
  Object.defineProperties(eventRecord.constructor.prototype, wrapFieldDefinitions);
}
 

On my side, eventRecord.constructor.prototype is the engine instrumented class (ModelClass / $meta present). After EventBuffer runs, wrapEndDate becomes getter-only and non-configurable on that prototype.
I confirmed the getter source at runtime:

const proto = Object.getPrototypeOf(eventRecord);
Object.getOwnPropertyDescriptor(proto, 'wrapEndDate').get.toString()
// => getter code from calendar-thin/lib/feature/EventBuffer.js

So later, when the engine commits and endBatch() runs, wrapEndDate = null fails because the setter was overwritten.
My backend only sends preamble/postamble (no wrapEndDate/wrapStartDate keys), so it’s not a payload field collision.

What is the recommended way to avoid this conflict?
Should EventBuffer avoid overwriting existing accessors (including inherited ones), or define these properties as configurable and/or preserve setters?
Is there a supported configuration/workaround to use Calendar EventBuffer with SchedulerPro ProjectModel + engine without hitting this error?
I tried reproducing it on your travel time demo, without success. Any guidance would be appreciated.


Post by alex.l »

Hi,

Actually, Calendar's EventBuffer feature does not support Pro version of EventModel. We need to adopt code to make that possible. I've opened a ticket for that https://github.com/bryntum/support/issues/12962
You can subscribe on ticket updates to be notified when it's done.

All the best,
Alex Lazarev

How to ask for help? Please read our Support Policy


Post Reply