nestjs-pg-notify icon indicating copy to clipboard operation
nestjs-pg-notify copied to clipboard

Database connection is not closed when closing the App

Open podplatnikm opened this issue 1 year ago • 1 comments
trafficstars

Hey @pvarentsov, I have one question/issue when working with nestjs-pg-notify.

So when I run tests (with jest) that use the PgNotifyServer (with connectMicroservice), I get the classic "open handlers" error on jest: A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.

I tracked down the issue and it seems that the connection to the Postgres Database is not closed when the app (hybrid) is being closed. I even turned on the Shutdown Hooks!

Any idea how I can avoid keeping open handlers with this and close the connection properly?

podplatnikm avatar Nov 20 '23 13:11 podplatnikm

Hi @podplatnikm, thanks for the issue.

I'm not sure, but maybe I faced with the same problem too. I have e2e tests in this project and I use afterAll jest hook to close testing application. For example, here. Do you use this hook?

pvarentsov avatar Nov 20 '23 18:11 pvarentsov