Solution skill
Prisma Memory Leak when using in NestJS app, reported by Jest
Complete solution
Shows how to fix prisma Memory Leak when using in NestJS app, reported by Jest. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
If you see memory issues with Prisma in NestJS tests, upgrade to Node.js 18 or newer; that solved it for the reporters. Also make sure every test suite calls prisma.$disconnect (or app.close) so Prisma cleans up its resources.
Steps
- If you see memory issues with Prisma in NestJS tests, upgrade to Node.js 18 or newer; that solved it for the reporters. Also make sure every test suite calls prisma.$disconnect (or app.close) so Prisma cleans up its resources. Note that Jest's --detectLeaks flag is experimental and unreliable, so do not treat its report as proof of a Prisma leak.
- Source: https://github.com/prisma/orm/issues/17925 (Prisma)
When to use
You are seeing this: Also make sure every test suite calls prisma.$disconnect (or app.close) so Prisma cleans up its resources. Use this skill when you run into "Prisma Memory Leak when using in NestJS app, reported by Jest".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Edge cases
- Also make sure every test suite calls prisma.$disconnect (or app.close) so Prisma cleans up its resources.
- Note that Jest's --detectLeaks flag is experimental and unreliable, so do not treat its report as proof of a Prisma leak. Source: https://github.com/prisma/orm/issues/17925 (Prisma)
Sources
- https://github.com/prisma/orm/issues/17925
Evidence
In gh:prisma/orm#17925, the issue was: ### Bug description In our (closed source) project, we added a lot of test for a new feature. That resulted in memory problems in our ci. We found, that Prisma is might be one of the problems. I created a minimal reproduction https://github.com/adrian-goe/prisma-nestjs-memory-leak-repoduction There is one test without using prisma app.controller.spec.ts and one using prisma [app-prisma.controller.spec.ts](https://github.. The verified answer: If you see memory issues with Prisma in NestJS tests, upgrade to Node.js 18 or newer; that solved it for the reporters. Also make sure every test suite calls prisma.$disconnect (or app.close) so Prisma cleans up its resources. Note that Jest's --detectLeaks flag is experimental and unreliable, so do not treat its report as proof of a Prisma leak.. Issue URL: https://github.com/prisma/orm/issues/17925
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_EP2aylCcqda6EtzVrrAf5g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Prisma Memory Leak when using in NestJS app, reported by Jest <span>— Vectle</span></a>