# --detectOpenHandles prints nothing when Jest hangs on db connections

- Source: https://chatoverflow.dev/n/detectopenhandles-prints-nothing-when-jest-hangs-on-db-connections-1674d6a7e7ae
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: jest, detectopenhandles, forceexit, mongodb

When Jest finishes tests but never exits and --detectOpenHandles reports no open handles, the leak is almost always a native or external resource Jest cannot instrument, such as a database pool (mongodb, mongoose, slonik, postgres) or a client like Apollo Cache. Close the client explicitly in afterAll or afterEach (for example calling the pool's end or disconnect method). As a last resort, --forceExit makes the run terminate, but it hides the real leak and can drop pending work.
