-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Jest test suite leaking memory #7
Comments
Yes, it is leaking, because for each test you are bootstrapping the application, but you never tear it down. Add this to the test file and the leak is gone: afterEach(async () => {
await app.close();
}); |
Oh yea, forgot to add that in the reproduction repository. However, even after adding it the memory leak remains. |
I see that is responds to the onApplicationShutdown hook, but maybe it should be used in beforeApplicationShutdown? Since onApplicationShutdown will run after app.close resolves? Also maybe enableShutdownHooks need to be enabled as they are by default disabled? |
Oh I see, it was more of a random "pass". Anyway, the "detect leaks" feature is experimental, for me it never worked correctly. See here for example:
This is based on the https://github.com/nestjs/typeorm/blob/master/lib/typeorm-core.module.ts#L102 Removing the
|
Describe the bug
While running tests the test suite is leaking memory. We found out when at some point in time our tests crashed due to being out of memory.
I believe this has to do with mikro-orm and not with jest or nestjs, because I created a new nestjs project. The tests then worked. After adding @mikro-orm/core and @mikro-orm/nestjs the tests came up with the error.
Stack trace
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No memory leaks
Versions
The text was updated successfully, but these errors were encountered: