vladimiry / ElectronMail

Unofficial ProtonMail Desktop App
GNU General Public License v3.0
1.5k stars 97 forks source link

Maximum call stack size exceeded #452

Closed valentinbonneaud closed 2 years ago

valentinbonneaud commented 2 years ago

Hi! I'm on the latest MacOS build and I get the following error message every now and then Maximum call stack size exceeded.

I've multiple accounts set up in my client, let me know if you want more details.

Screenshot 2021-10-11 at 09 14 00
vladimiry commented 2 years ago

There is not enough information to say something specific.

valentinbonneaud commented 2 years ago

Sure, let me know if you need more information!

vladimiry commented 2 years ago

Thanks for the details. The log file was helpful in detecting the issue cause. The error gets triggered in the _vacuumIndex function of the https://github.com/ndx-search/ndx library used for indexing the mails for local search. The function uses a recursion technique and the recursion depth has a limit in JavaScript runtime and you hit the limit with so large dataset so the error occurs.

I will see what I can do about that. The simplest option is to stop using the "vaccum" feature of "ndx" library which will end up with the data related to the removed mails to remain in the memory/search-index. The search index is not stored on ssd/hdd but in-memory only so I think this option is acceptable. The more time-consuming option is to rewrite the "_vacuumIndex" function so it doesn't use the recursion technique (recursion algorithms are normally not a great option if scaling matters).

According to the code logic, you should get the error when you remove emails.

The error should go away if you disable the "Full-text search" toggle in the "General" app section.

vladimiry commented 2 years ago

@valentinbonneaud, here is the WIP build for you to test with disabled "search index vacuuming" feature (see the build job link if needed). The build comes with the most recent @protonmail web clients stack (has been updated since v4.12.9). Please report the issue status then.