vendure
vendure copied to clipboard
fix(core): Update indexer controller to avoid TypeORM memory leak
Description
Previously I've tried to fix the search index plugin in order to avoid a memory leak I've tought was caused because of multiple channels. In order to fix it, I've changed the default indexer controller to use queryBuilder
to fetch data from the database.
Since that, I've discovered a bug in TypeORM (at least I think it's related to TypeORM), which causes the memory leak issue, and also discovered that the memory leak still exists in the indexer controller when I do a partial search index update, initiated from the admin-ui.
To avoid that, I've updated the indexer controller once again to use TypeORM repositories (instead of query builder), but instead of simply join tables, we have to explicitly say that the relationLoadStrategy
should be query
instead of join
(which is the default behavior I think). This works properly as far as I can see, otherwise, if you would join multiple tables, TypeORM will eat all your memory instead of returning with the data you've requested.
PS.: I think this TypeORM issue was introduced with TypeORM 0.3.20, as I didn't saw this issue in earlier versions of Vendure either, only since 2.2.x
Breaking changes
Everything should work as before.
Screenshots
You can add screenshots here if applicable.
Checklist
📌 Always:
- [x] I have set a clear title
- [x] My PR is small and contains a single feature
- [x] I have checked my own PR
👍 Most of the time:
- [x] I have added or updated test cases
- [x] I have updated the README if needed