Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prisma): Too many idle db connections #646

Merged
merged 2 commits into from
Jun 20, 2024

Conversation

sashko9807
Copy link
Member

@sashko9807 sashko9807 commented Jun 20, 2024

When importing a service through the provider interface of the module, NestJS creates new instance each time that provider service is referenced.

For example if we have 20 modules which have PrismaService as a provider, a 20 instances of PrismaService will be created, which could result in many idle db connections.

To fix this:

  • Added PrismaModule which would export PrismaService
  • Replaced providers: [PrismaService] with imports: [PrismaModule] which ensures only a single instance of PrismaService is created.

Copy link

github-actions bot commented Jun 20, 2024

✅ Tests will run for this PR. Once they succeed it can be merged.

@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Jun 20, 2024
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Jun 20, 2024
@imilchev imilchev merged commit 39e39a8 into podkrepi-bg:master Jun 20, 2024
10 of 11 checks passed
gparlakov pushed a commit to gparlakov/podkrepi-bg-api that referenced this pull request Jun 21, 2024
* fix(prisma): Add prisma module
Needed to prevent creation of many PrismaService instances

* chore: Replace PersonService provider with PersonModule import
gparlakov pushed a commit to gparlakov/podkrepi-bg-api that referenced this pull request Jun 30, 2024
* fix(prisma): Add prisma module
Needed to prevent creation of many PrismaService instances

* chore: Replace PersonService provider with PersonModule import
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.

2 participants