From ce5267768fb32cba8e8da63460a869f5132b99e7 Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Tue, 22 Jul 2025 16:09:21 -0400 Subject: [PATCH] fix(core): remove graph creation from postinstall hook Fixes: #31649 --- packages/nx/bin/post-install.ts | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/packages/nx/bin/post-install.ts b/packages/nx/bin/post-install.ts index 9822b4575e861..6517b07024585 100644 --- a/packages/nx/bin/post-install.ts +++ b/packages/nx/bin/post-install.ts @@ -11,34 +11,22 @@ import { readNxJson } from '../src/config/nx-json'; import { logger } from '../src/utils/logger'; import { setupWorkspaceContext } from '../src/utils/workspace-context'; +// The post install is not critical, to avoid any chance that it may hang +// we will kill this process after 30 seconds. +const postinstallTimeout = setTimeout(() => { + logger.verbose('Nx post-install timed out.'); + process.exit(0); +}, 30_000); + (async () => { const start = new Date(); try { if (isMainNxPackage() && fileExists(join(workspaceRoot, 'nx.json'))) { assertSupportedPlatform(); - setupWorkspaceContext(workspaceRoot); - if (daemonClient.enabled()) { - try { - await daemonClient.stop(); - } catch (e) {} - } - const tasks: Array> = [ - buildProjectGraphAndSourceMapsWithoutDaemon(), - ]; + if (isNxCloudUsed(readNxJson())) { - tasks.push(verifyOrUpdateNxCloudClient(getCloudOptions())); + await verifyOrUpdateNxCloudClient(getCloudOptions()); } - - process.env.NX_DAEMON = 'false'; - await Promise.all( - tasks.map((promise) => { - return promise.catch((e) => { - if (process.env.NX_VERBOSE_LOGGING === 'true') { - console.warn(e); - } - }); - }) - ); } } catch (e) { logger.verbose(e); @@ -48,6 +36,7 @@ import { setupWorkspaceContext } from '../src/utils/workspace-context'; `Nx postinstall steps took ${end.getTime() - start.getTime()}ms` ); + clearTimeout(postinstallTimeout); process.exit(0); } })();