Comments (4)
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();
});
from nestjs.
Oh yea, forgot to add that in the reproduction repository. However, even after adding it the memory leak remains.
from nestjs.
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?
from nestjs.
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:
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?
This is based on the @nestjs/typeorm
module, so I'd say that should be correct when it's done by the author of nest.
https://github.com/nestjs/typeorm/blob/master/lib/typeorm-core.module.ts#L102
Removing the onApplicationShutdown
bit and explicitly calling orm.close()
does not help. But I really believe this is more of a jest failure than actual leak. When I tried to duplicate the test 8 times and allowed garbage collection and heap logging, I can see the memory usage is consistent:
➜ nest-mikro-orm-jest-leak git:(master) ✗ node --expose-gc ./node_modules/.bin/jest --runInBand --logHeapUsage --config ./test/jest-e2e.json
PASS test/app1.e2e-spec.ts (62 MB heap size)
PASS test/app4.e2e-spec.ts (75 MB heap size)
PASS test/app5.e2e-spec.ts (76 MB heap size)
PASS test/app3.e2e-spec.ts (76 MB heap size)
PASS test/app7.e2e-spec.ts (76 MB heap size)
PASS test/app6.e2e-spec.ts (76 MB heap size)
PASS test/app2.e2e-spec.ts (76 MB heap size)
PASS test/app.e2e-spec.ts (76 MB heap size)
from nestjs.
Related Issues (20)
- Metadata for entity CustomBaseEntity not found HOT 4
- MetadataError: Duplicate entity names are not allowed: "User" HOT 7
- Entity id is not populated HOT 23
- Error when trying to query an entity from the repository HOT 3
- How can I take some actions after it successfully connects or fails? HOT 1
- Cannot persist an entity with a 1-to-1 reference to another entity HOT 5
- Cannot persist Read-Only association HOT 3
- Cannot get `@UseRequestContext` to work in a REQUEST scoped BullMQ processor HOT 4
- Populating Nested Field returns the wrong number of associated entities HOT 5
- Relations not working in nestjs HOT 6
- Issue when running tests after upgrading to 5.2.2
- Bump version, compatible with MikroORM V6 HOT 6
- Nestjs, mikro-orm and postgres can't generate table automatically HOT 2
- vitest + mikroorm collection error HOT 4
- findByCursor method not working on sqlite HOT 1
- Testing with multiple testing modules in NestJS and Jest leads to an error during metadata discovery HOT 2
- Issues running Mikro-ORM with NestJS on Vercel platform HOT 1
- MikroOrmMiddleware not found in e2e tests
- feat: add Transactional Decorator HOT 1
- How to listen to connection status?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs.