Premium support for our pure JavaScript UI components


Post by jandresampaio »

Hi,

We're having the following error and crash in production, when re-rendering Scheduler. Is there any reason why this might be happening using Angular prod build? This does not happen in dev mode.
First time it loads correctly, but if user leaves the view and reenters it, it seems to crash on the triggerBeforeUpdate function, when setting assignmentsData, following the Scheduler constructor.

Error reentering Scheduler in Angular app - prod build.PNG
Error reentering Scheduler in Angular app - prod build.PNG (235.53 KiB) Viewed 1918 times
Error reentering Scheduler in Angular app 2 - prod build.PNG
Error reentering Scheduler in Angular app 2 - prod build.PNG (30.73 KiB) Viewed 1916 times

Do we have to manually destroy some of the Scheduler properties (stores, etc) when using Angular 10?

Thanks


Post by mats »

Very hard to say without a test case. Try to set a breakpoint in your two environments and find out what is different?


Post by jandresampaio »

Yes, in the meantime I've managed to replicate this using the attached test case. Can you please check it? You have to run it with production build.
Run with http-server, for instance, in angular 8 folder (which is using Angular 10), inside dist folder.

Then, click on the links above (sorry about the duplicate navigate anchor links)

Evidence - navigate between components.PNG
Evidence - navigate between components.PNG (76.15 KiB) Viewed 1907 times

Navigate to scheduler and then to the Test component. Click again in Scheduler component to confirm the error.

Attachments
angular-10.zip
(9.25 MiB) Downloaded 129 times

Post by alex.l »

Hi jandresampaio,

Thanks for the demo, I was able to run it and reproduced the bug you mentioned.
The problem is that Angular destroys only HTML markup and not the Scheduler instance, stores, etc. So, you need to extend your code with a destroy function on routing, or not destroy it at all but show/hide.
We have an example how to manage that here: https://bryntum.com/examples/scheduler/angular/advanced/dist/advanced
Please, take a look, it should help you to handle this in a proper way.

Good luck,
Alex

All the best,
Alex


Post by jandresampaio »

Hi,

Destroying Scheduler inside Angular OnDestroy should perform those operations, but it doesn't.
Is the link OK? I see the Not Found page.

Thanks


Post by alex.l »

You right, the /scheduler1 part in the end should be removed. The link is updated. But you need to find this example in our sources to see the code.

All the best,
Alex


Post by jandresampaio »

OK. Reuse strategy is not an option for us. We don't have a specific route for Scheduler. The components are generated at runtime (using angular dynamic components) and this could introduce side effects.

Why does schedulerInstance.destroy() does not perform the dispose operations? What are the additional operations we could do on our side, before the bug is fixed?


Post by alex.l »

It should work well, we have ngOnDestroy in scheduler.component.ts with the next code:

    /**
     * Destroys component
     */
    ngOnDestroy(): void {
        if (this.schedulerInstance) {
            this.schedulerInstance.destroy();
        }
    }

I have modified our advanced example for you. I changed angular version to 10, and used default init/destroy strategy. In console logs you will see

initializing scheduler 2
destroying scheduler2

I checked it using debugger in our scheduler wrapper, it calls schedulerInstanse.destroy() and it works.

Please review and compare with your strategy.
dist/ folder is there, so just run http-server ./, same as in your example.

I hope it helps to figure it out. Please let us know if you will have problems.

All best,
Alex

Attachments
advanced-10.zip
(3.53 MiB) Downloaded 198 times

All the best,
Alex


Post by jandresampaio »

I'm not following...your zip doesn't have destroy being called on scheduler instances. It's using the router reuse strategy, so the error is not triggered.

In my example, where we don't use the Router Reuse strategy, I've called destroy on the schedulerInstance and the error occurs..


Post by alex.l »

Did you run it? It doesn't. Please check logs and the app deeply.

All the best,
Alex


Post Reply