CI/CD error Jest: A worker process has failed to exit gracefully
Something in the test run (an open handle, timer, or connection) is keeping the Node process alive after the tests themselves finished.
Why this happens
- A test opened a DB connection, server, or timer and never closed/cleared it
- A dependency leaks an open handle (common with some HTTP or DB client libraries) that Jest can't force-close
How to fix it
- Run with `--detectOpenHandles` locally to find exactly what's still open
- Explicitly close everything you open in `afterAll`/`afterEach` (DB connections, servers, `clearInterval`/`clearTimeout`)
- Use `--forceExit` in CI only as a stopgap while you track down the real leak, not as a permanent fix