Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak When modify entity field in the admin page #3042

Closed
zhuyicheng666 opened this issue Apr 26, 2024 · 16 comments
Closed

memory leak When modify entity field in the admin page #3042

zhuyicheng666 opened this issue Apr 26, 2024 · 16 comments

Comments

@zhuyicheng666
Copy link

zhuyicheng666 commented Apr 26, 2024

Describe the bug
memory leak When modify entity field in the admin page
url: /#Admin/fieldManager/scope=Account&type=text&create=true

To Reproduce (MANDATORY, DO NOT REMOVE)
In this page /#Admin/fieldManager/scope=Account&type=text&create=true, create a new field or
In this page /#Admin/fieldManager/scope=Account&field=accountNature, modify the label.
Expected behavior
The page is running normally and a "Saved" prompt appears.

Screenshots

EspoCRM version
8.2.0

Additional context
We have discovered that a statement [this.off('sync');] is missing in the load function within client/src/language.js, but it is present in client/src/metadata.js.

@yurikuzn
Copy link
Contributor

What do you mean by 'memory leak'. I tried on two instances, the "Saved" alert appeared. It does not appear for you? What exactly happens?

@zhuyicheng666
Copy link
Author

My chrome will be frozon and nothing responds when I click on anything。

@yurikuzn
Copy link
Contributor

Any JS errors in the browser console?

@zhuyicheng666
Copy link
Author

no。Chrome has frozen due to an infinite loop.

@yurikuzn
Copy link
Contributor

Strange. I'll try to figure out but the fact that I can't reproduce complicate things. Does it happen only if you change the label or happens if you change any parameter?

Could you point where exactly the loop happens?

@zhuyicheng666
Copy link
Author

zhuyicheng666 commented Apr 26, 2024

When I add this.off('sync'); in the function load which in the client/src/languages and the problem has solved. The whole function is

 load(callback, disableCache, loadDefault) {
        this.off('sync');
        if (callback) {
            this.once('sync', callback);
        }

        if (!disableCache) {
            if (this.loadFromCache(loadDefault)) {
                this.trigger('sync');

                return new Promise(resolve => resolve());
            }
        }

        return new Promise(resolve => {
            this.fetch(loadDefault)
                .then(() => resolve());
        });
    }

the loop i think is about 'sync' event.

@yurikuzn
Copy link
Contributor

Thanks for info. Do you have any custom code that calls the load method of the language object?

@zhuyicheng666
Copy link
Author

zhuyicheng666 commented Apr 26, 2024

No custom code. I set 'useCache' => true in data/config.php and use production mode.

@yurikuzn
Copy link
Contributor

yurikuzn commented Apr 26, 2024

I checked the whole codebase and have not found the 'sync' event being used on the language object. The 'callback' is never passed (it's deprecated). No idea why this happens on your instance. I might add the 'off' for v8.2 hotfix, but need to refactor the method for the future versions so that only promise is used.

@yurikuzn
Copy link
Contributor

bfed154

@yurikuzn
Copy link
Contributor

It's not related. It's another object.

@zhuyicheng666
Copy link
Author

In client\src\views\site\navbar.js

this.listenTo(this.getHelper().language, 'sync', () => update());

@yurikuzn
Copy link
Contributor

yurikuzn commented Apr 26, 2024

This could be a reason.

EDIT. Unlikely. It should not prevent 'sync' from firing.

@zhuyicheng666
Copy link
Author

maybe something wrong where excuting '() => update()' .because if not removing the listener on language, it may add a same one on it when update()

@yurikuzn
Copy link
Contributor

yurikuzn commented Apr 26, 2024

Yes. It's possible that code fails within update() execution, and then not proceeded to return new Promise(resolve => resolve()); in the load method. But usually it should be seen in the console.

@eymen-elkum
Copy link
Contributor

@zhuyicheng666 do you have 3rd party extensions

@yurikuzn yurikuzn closed this as not planned Won't fix, can't repro, duplicate, stale Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants