Repository navigation
Description
Hi! We hit an OOM after moving to Prisma 7 and tracked it down to @prisma/debug.
debugCall pushes every call's arguments into argsHistory (last 100 calls), whether the namespace is enabled or not. In Prisma 7 that includes debug('query plan created', plan) in ClientEngine.ts, plus the SQL and parameters logged by @prisma/adapter-pg. So the plans of roughly the last 25 queries stay in memory, whatever their size.
For big createMany calls that adds up fast: our service (256 MB heap) crashed while inserting 21 batches of 1000 rows. It also partly undoes #29382, which kept createMany plans out of the plan cache because they are so large.
Repro (Prisma 7.10.0, adapter-pg 7.10.0, Postgres 16, Node 24, DEBUG unset): 40 createMany of 1000 rows on a 6-column model, heap measured after global.gc().
| after 40 calls | |
|---|---|
| default | +81 MB |
queryPlanCacheMaxSize: 0 |
+81 MB |
| debug histories cleared after each call | +11 MB |
Script
// node --expose-gc repro.js
const { PrismaClient } = require("@prisma/client")
const { PrismaPg } = require("@prisma/adapter-pg")
const prisma = new PrismaClient({ adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL }) })
const rows = (k) => Array.from({ length: 1000 }, (_, i) => ({
label: `row ${k}-${i}`, code: `C${i % 97}`, note: null, amount: "1.25", day: new Date(),
}))
;(async () => {
global.gc()
const base = process.memoryUsage().heapUsed
for (let k = 1; k <= 40; k++) await prisma.row.createMany({ data: rows(k) })
global.gc()
console.log(`+${Math.round((process.memoryUsage().heapUsed - base) / 1048576)} MB retained`)
await prisma.$disconnect()
})()Model: Row { id Int @id @default(autoincrement()), label String, code String, note String?, amount Decimal @db.Decimal(12, 2), day DateTime }
It's a different cause from #30487: turning the plan cache off changes nothing here.
Suggested fix: when the namespace is disabled, store a short summary of each argument instead of the object itself: strings and primitives as is, errors as name: message, anything else as [Object]. getLogs() still gets useful messages, and the existing @prisma/debug tests pass. With that change applied to both copies, retention stays flat in our runs. Happy to open a PR against v7 if that works for you.
For now we work around it by patching both copies of @prisma/debug with pnpm patch.
Activity
damiommccreary commentedon Sep 29, 2026
damiommccreary commentedon Sep 29, 2026
damiommccreary commentedon Sep 29, 2026
wmadden-electric commentedon Nov 19, 2026
Fixed on
v7by #30556.fix(debug): avoid retaining query objects when logging is disabled (p…