From bd192a61258191e89d6df7a5ffa99c517f1a0425 Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli Date: Wed, 2 Oct 2024 13:23:47 -0400 Subject: [PATCH] fix(core): change getCache signature to only accept options (#28248) ## Current Behavior `getCache` has an argument for nxjson. This breaks nx cloud when using the db cache. ## Expected Behavior `getCache` now only has options as an argument, and uses `readNxJson` in the function body ## Related Issue(s) Fixes # (cherry picked from commit 161a3f1b0b883bfb4aef3bf89506ffb1d5bcb3a0) --- packages/nx/src/tasks-runner/cache.ts | 11 ++++------- packages/nx/src/tasks-runner/task-orchestrator.ts | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/nx/src/tasks-runner/cache.ts b/packages/nx/src/tasks-runner/cache.ts index 3416e555b817b..33882bcb210d9 100644 --- a/packages/nx/src/tasks-runner/cache.ts +++ b/packages/nx/src/tasks-runner/cache.ts @@ -29,17 +29,14 @@ export type CachedResult = { }; export type TaskWithCachedResult = { task: Task; cachedResult: CachedResult }; -export function getCache( - nxJson: NxJsonConfiguration, - options: DefaultTasksRunnerOptions -): DbCache | Cache { +// Do not change the order of these arguments as this function is used by nx cloud +export function getCache(options: DefaultTasksRunnerOptions): DbCache | Cache { + const nxJson = readNxJson(); return process.env.NX_DISABLE_DB !== 'true' && (nxJson.enableDbCache === true || process.env.NX_DB_CACHE === 'true') ? new DbCache({ // Remove this in Nx 21 - nxCloudRemoteCache: isNxCloudUsed(readNxJson()) - ? options.remoteCache - : null, + nxCloudRemoteCache: isNxCloudUsed(nxJson) ? options.remoteCache : null, }) : new Cache(options); } diff --git a/packages/nx/src/tasks-runner/task-orchestrator.ts b/packages/nx/src/tasks-runner/task-orchestrator.ts index 9910009cc086a..76b1114590ab0 100644 --- a/packages/nx/src/tasks-runner/task-orchestrator.ts +++ b/packages/nx/src/tasks-runner/task-orchestrator.ts @@ -36,7 +36,7 @@ import type { TaskDetails } from '../native'; export class TaskOrchestrator { private taskDetails: TaskDetails | null = getTaskDetails(); - private cache: DbCache | Cache = getCache(this.nxJson, this.options); + private cache: DbCache | Cache = getCache(this.options); private forkedProcessTaskRunner = new ForkedProcessTaskRunner(this.options); private tasksSchedule = new TasksSchedule(