MaxListenersExceededWarning: Possible EventEmitter memory leak detected

I have a test suite (node test) that tests our Prisma data model. Using 6.14 and earlier, everything worked fine. But starting with 6.15 (and still happens in 6.16.1), I started getting this warning in the console: MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit at _addListener (file:///Users/marcus/xsignal/messaging-common/node_modules/@neondatabase/serverless/index.mjs:322:10) at kn.addListener (file:///Users/marcus/xsignal/messaging-common/node_modules/@neondatabase/serverless/index.mjs:325:8) at Un._release (file:///Users/marcus/xsignal/messaging-common/node_modules/@neondatabase/serverless/index.mjs:1129:77) at kn.release (file:///Users/marcus/xsignal/messaging-common/node_modules/@neondatabase/serverless/index.mjs:1129:39) at NeonTransaction.commit (file:///Users/marcus/xsignal/messaging-common/node_modules/@prisma/adapter-neon/dist/index.mjs:565:17) at <anonymous> (/Users/marcus/xsignal/messaging-common/node_modules/@prisma/driver-adapter-utils/src/binder.ts:123:23) { (note, I get the same issue when using the PG driver instead of the Neon driver) Has anyone else seen this? I'm using a single Prisma client for my tests. Thanks, Marcus
1 Reply
Prisma AI Help
Prisma AI Help3mo ago
You selected the bot's instantaneous insights. Let me compile your answer right away! Short answer: yes, others are seeing this after upgrading, and it’s likely related to listener handling introduced around 6.15 with the new driver adapters. What we know from the sources: - There’s an open issue for MaxListenersExceededWarning with adapter-pg in 6.15.0, caused by error handlers being re-attached to pooled clients without removing old ones, leading to >10 listeners on reused clients. Downgrading to 6.14.x avoids it. [adapter-pg issue]. - Similar listener accumulation warnings have appeared historically when multiple PrismaClient instances or event listeners are added repeatedly (e.g., process signals, $on handlers) without being removed. [8055; 6584; 16335]. - Users reported the warning with both Neon and pg paths after 6.15, consistent with the adapter layer. [adapter-pg issue]. Pragmatic workarounds (until a fix lands): - Temporarily pin Prisma and the adapter to 6.14.x where you didn’t see the warning. [adapter-pg issue]. - Ensure a single PrismaClient instance per test process and avoid re-initializing between tests. Listener growth often correlates with repeated client creation. [8989; 17171]. - If you must stay on 6.15+/6.16, you can raise the listener cap as a stopgap: - Node EventEmitter global limit: events.setMaxListeners(Infinity). Note: this masks the symptom and should be used cautiously. [adapter-pg issue]. If you can share a minimal repro with your test runner and adapter config (Neon vs pg), it’ll help confirm whether you’re hitting the same pooled-client listener accumulation noted in 6.15. [adapter-pg issue]. Summary: This is a known regression area starting in 6.15 with driver adapters. Downgrade to 6.14.x or use the temporary listener cap, and watch the linked issue for a fix. [adapter-pg issue]. ✅ Great, thanks for letting us know that this solved your question!

Did you find this page helpful?