nestjs / mongoose

Mongoose module for Nest framework (node.js) 🍸
https://nestjs.com
MIT License
530 stars 118 forks source link

MongoDB Connections not Closing #2188

Closed cillaeslopes closed 4 months ago

cillaeslopes commented 4 months ago

Is there an existing issue for this?

Current behavior

MongoDB connections doesn't seem to be closed after request is over. I've been monitoring the number of open connections on Compass and it gets higher and higher.

When I start the application it starts with 13 connections image

If I simulate a high number of simultaneos requests it goes up to 35 connections image

Then it never gets back to 13 so it only gets higher. image

Minimum reproduction code

https://github.com/cillaeslopes/nest-mongo-test

Steps to reproduce

Then in another terminal:

And observe mongodb connections with:

Expected behavior

I'd expect the number of connections to get back to initial state once the requests are done

Package version

10.0.2

mongoose version

8.0.1

NestJS version

10.3.2

Node.js version

20.11.1

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 4 months ago

Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the #⁠ 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.