Describe the bug
__tests__/server/shutdown.test.js fails with a timeout after 5000 ms because mock connections aren’t removed from server.connections during shutdown.
server.stop() waits until shutdownTimeout expires, and Jest times out.
Mock methods like mockConnState.close() or mockSocket.destroy() don’t emit the real events ('close', 'end') expected by _performGracefulShutdown().
This happens both inside the Dev Container and locally (just running npm install + npm test).
To Reproduce
→ shutdown.test.js times out after 5000 ms.
Same result if tests are run inside the Docker dev container.
Expected behavior
server.stop() should gracefully close all mock connections and complete before reaching the shutdown timeout, allowing the test to finish normally.
Console output
FAIL __tests__/server/shutdown.test.js
● should rollback transactions during shutdown
Exceeded timeout of 5000 ms for a test.
Jest did not exit one second after the test run has completed.
Environment
| Component |
Version / Info |
| pg-wire-mock |
main (1.1.0) |
| Node.js |
v22.x |
| OS |
Windows 11 / Ubuntu 22.04 / Docker base image |
| Command |
npm test -- --runInBand |
Additional context
- Mock connections persist in
server.connections, blocking _performGracefulShutdown().
- Increasing Jest timeout only hides the issue.
Likely fix: mock sockets should emit 'close'/'end' so cleanup runs properly.
Describe the bug
__tests__/server/shutdown.test.jsfails with a timeout after 5000 ms because mock connections aren’t removed fromserver.connectionsduring shutdown.server.stop()waits untilshutdownTimeoutexpires, and Jest times out.Mock methods like
mockConnState.close()ormockSocket.destroy()don’t emit the real events ('close','end') expected by_performGracefulShutdown().This happens both inside the Dev Container and locally (just running
npm install+npm test).To Reproduce
npm test -- --runInBand→
shutdown.test.jstimes out after 5000 ms.Same result if tests are run inside the Docker dev container.
Expected behavior
server.stop()should gracefully close all mock connections and complete before reaching the shutdown timeout, allowing the test to finish normally.Console output
Environment
npm test -- --runInBandAdditional context
server.connections, blocking_performGracefulShutdown().Likely fix: mock sockets should emit
'close'/'end'so cleanup runs properly.