## 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

1. 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.

2. _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
