nestjs / mongoose

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

OpenHandles after migration from mongoose 5.13 to 6.1 #1160

Closed Branchverse closed 2 years ago

Branchverse commented 2 years ago

Is there an existing issue for this?

Current behavior

Running the same tests after upgrading causes the tests to not run through and provide a warning of open handles recommending the --detectOpenHandles option for the tests. This option also does not show anything, it just surpresses the warning.

The issue seems to come through ConfigServices since the updated mongoose without it works!

The tests don't run through and you have to manually stop them

Minimum reproduction code

https://github.com/Branchverse/Mongoose-version-issue

Steps to reproduce

Go to https://github.com/Branchverse/Mongoose-version-issue

Clone the repository

Follow the README.md

Expected behavior

Run the tests and not have any openHandles, or have --detectOpenHandles test option atleast show me where the open handle is

Package version

9.0.1

mongoose version

6.1.2

NestJS version

8.0.0

Node.js version

16.13

In which operating systems have you tested?

Other

No response

jmcdo29 commented 2 years ago

After digging into this a bit, it looks like we already have a fix in place, the .asPromise()chained onto mongoose.createConnection() in the create providers method. Once I added this locally (going into node_modules) everything closed out as expected.

@kamilmysliwiec do you think we could get a patch pushed up soon?

kamilmysliwiec commented 2 years ago

Just published 9.0.2