Skip to content

Commit

Permalink
fix(core): read nx.json in the DaemonClient constructor instead of th…
Browse files Browse the repository at this point in the history
…e module (#23033)
  • Loading branch information
MaxKless committed Apr 26, 2024
1 parent b8e6ebb commit d3454ed
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/nx/src/daemon/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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
Expand Down Expand Up @@ -447,7 +453,7 @@ export class DaemonClient {
}
}

export const daemonClient = new DaemonClient(readNxJson());
export const daemonClient = new DaemonClient();

function isDocker() {
try {
Expand Down

0 comments on commit d3454ed

Please sign in to comment.