From d3454ede6284efdaa083340a37b8eba2ca104fee Mon Sep 17 00:00:00 2001 From: MaxKless <34165455+MaxKless@users.noreply.github.com> Date: Fri, 26 Apr 2024 16:42:12 +0200 Subject: [PATCH] fix(core): read nx.json in the DaemonClient constructor instead of the module (#23033) --- packages/nx/src/daemon/client/client.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/nx/src/daemon/client/client.ts b/packages/nx/src/daemon/client/client.ts index 6ebf3d72e851c..3bd55fdf96cb1 100644 --- a/packages/nx/src/daemon/client/client.ts +++ b/packages/nx/src/daemon/client/client.ts @@ -48,7 +48,13 @@ enum DaemonStatus { } export class DaemonClient { - constructor(private readonly nxJson: NxJsonConfiguration) { + private readonly nxJson: NxJsonConfiguration | null; + constructor() { + try { + this.nxJson = readNxJson(); + } catch (e) { + this.nxJson = null; + } this.reset(); } @@ -70,8 +76,8 @@ export class DaemonClient { if (this._enabled === undefined) { // TODO(v19): Add migration to move it out of existing configs and remove the ?? here. const useDaemonProcessOption = - this.nxJson.useDaemonProcess ?? - this.nxJson.tasksRunnerOptions?.['default']?.options?.useDaemonProcess; + this.nxJson?.useDaemonProcess ?? + this.nxJson?.tasksRunnerOptions?.['default']?.options?.useDaemonProcess; const env = process.env.NX_DAEMON; // env takes precedence @@ -447,7 +453,7 @@ export class DaemonClient { } } -export const daemonClient = new DaemonClient(readNxJson()); +export const daemonClient = new DaemonClient(); function isDocker() { try {