From 999abe9656d036da8df8ef73fb158152d4c900e9 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Thu, 19 Sep 2024 14:58:10 -0400 Subject: [PATCH] fix(core): do not check cache validity when putting into the cache (#28004) ## Current Behavior Invalid cache message shown twice. ## Expected Behavior Invalid cache message shown once. ## Related Issue(s) Fixes # --- packages/nx/src/tasks-runner/cache.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/nx/src/tasks-runner/cache.ts b/packages/nx/src/tasks-runner/cache.ts index f24053520d81f..bbddf348b7d8d 100644 --- a/packages/nx/src/tasks-runner/cache.ts +++ b/packages/nx/src/tasks-runner/cache.ts @@ -18,6 +18,7 @@ import { readNxJson } from '../config/nx-json'; import { verifyOrUpdateNxCloudClient } from '../nx-cloud/update-manager'; import { getCloudOptions } from '../nx-cloud/utilities/get-cloud-options'; import { isCI } from '../utils/is-ci'; +import { output } from '../utils/output'; export type CachedResult = { terminalOutput: string; @@ -97,7 +98,6 @@ export class DbCache { outputs: string[], code: number ) { - await this.assertCacheIsValid(); return tryAndRetry(async () => { this.cache.put(task.hash, terminalOutput, outputs, code); @@ -191,13 +191,16 @@ export class DbCache { // custom directory, and check if the entries are there when the main db // cache misses. if (isCI() && !this.cache.checkCacheFsInSync()) { - const warning = [ + const warningLines = [ `Nx found unrecognized artifacts in the cache directory and will not be able to use them.`, `Nx can only restore artifacts it has metadata about.`, `Read about this warning and how to address it here: https://nx.dev/troubleshooting/unknown-local-cache`, ``, - ].join('\n'); - console.warn(warning); + ]; + output.warn({ + title: 'Unrecognized Cache Artifacts', + bodyLines: warningLines, + }); } } }