Skip to content

fix(adapter-pg): error event listener leak#28057

Merged
jacek-prisma merged 2 commits intoprisma:mainfrom
Zhincore:main
Sep 8, 2025
Merged

fix(adapter-pg): error event listener leak#28057
jacek-prisma merged 2 commits intoprisma:mainfrom
Zhincore:main

Conversation

@Zhincore
Copy link
Copy Markdown
Contributor

@Zhincore Zhincore commented Sep 7, 2025

Fixes an issue where when executing enough transactions in quick succession and pg-pool starts to reuse clients, error handlers are re-attached to them but old ones aren't removed, causing the MaxListenersExceededWarning and supposedly a memory leak.

Closes #28037

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Sep 7, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@jacek-prisma jacek-prisma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the contribution

@jacek-prisma jacek-prisma merged commit d368e9f into prisma:main Sep 8, 2025
396 of 397 checks passed
@afonsomatos
Copy link
Copy Markdown

@jacek-prisma How do we use this? The final version is 6.15.0.

@clemens
Copy link
Copy Markdown
Contributor

clemens commented Sep 9, 2025

Does this actually fix the problem? Just from looking at the code, it seems to me that it just makes it more unlikely, right? Wouldn't the error still appear if there were more concurrent transactions than the respective max listeners setting allows?

@jacek-prisma
Copy link
Copy Markdown
Contributor

@afonsomatos it'll be in the next minor release which will release soon
@clemens it should fix the problem, because concurrent transactions will not re-use connections, so each connection should have 1 listener - this problem would occur when connections were re-used

@PatrickRogg
Copy link
Copy Markdown

@jacek-prisma I just quickly tried out v6.16.0-dev.37 and the issue still happening. Is this commit included in there already?

@Zhincore
Copy link
Copy Markdown
Contributor Author

@PatrickRogg It helped for me, the issue is gone. Make sure you updated the adapter-pg package specifically

@PatrickRogg
Copy link
Copy Markdown

Ah, my bad. The package wasn't updated in my turbo repo. Works now. Thanks for fixing this @Zhincore

jacek-prisma pushed a commit that referenced this pull request Sep 30, 2025
This PR fixes the same event listener leak for `adapter-mariadb` that
was resolved in `adapter-pg` (#28057).
aqrln pushed a commit that referenced this pull request Sep 30, 2025
This PR fixes the same event listener leak for `adapter-mariadb` that
was resolved in `adapter-pg` (#28057).
aqrln pushed a commit that referenced this pull request Sep 30, 2025
This PR fixes the same event listener leak for `adapter-mariadb` that
was resolved in `adapter-pg` (#28057).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MaxListenersExceededWarning with adapter-pg

6 participants