From 8c50b7f3afd9bc9790a19e75fb318f4516a4832d Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Thu, 8 May 2025 18:35:01 -0400 Subject: [PATCH] fix(core): only cleanup db connection on exit (#31137) ## Current Behavior db connections are cleaned up on SIGTERM, SIGHUP, SIGINT, AND exit. On SIGTERM, SIGHUP, and SIGINT, the process exits there.. which short circuits other SIGTERM, SIGHUP, and SIGINT handlers. ## Expected Behavior db connections are only cleaned up when the process actually exits. It does not exit the process here in response to any signals. ## Related Issue(s) Fixes # --- packages/nx/bin/nx.ts | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/packages/nx/bin/nx.ts b/packages/nx/bin/nx.ts index d8a6a0f62b..cba4fe9946 100644 --- a/packages/nx/bin/nx.ts +++ b/packages/nx/bin/nx.ts @@ -283,26 +283,8 @@ const getLatestVersionOfNx = ((fn: () => string) => { return () => cache || (cache = fn()); })(_getLatestVersionOfNx); -function nxCleanup(signal?: NodeJS.Signals) { - removeDbConnections(); - if (signal) { - process.exit(signalToCode(signal)); - } else { - process.exit(); - } -} - process.on('exit', () => { - nxCleanup(); -}); -process.on('SIGINT', () => { - nxCleanup('SIGINT'); -}); -process.on('SIGTERM', () => { - nxCleanup('SIGTERM'); -}); -process.on('SIGHUP', () => { - nxCleanup('SIGHUP'); + removeDbConnections(); }); main();