From 94b12602ac7a37849b55dd401b0c1207f3438564 Mon Sep 17 00:00:00 2001 From: Mario Campos Date: Fri, 19 Jun 2026 15:41:47 -0500 Subject: [PATCH] Refactor cache file reading to check for existence before attempting to read --- lib/entry-points.js | 6 ++---- src/cache.ts | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index 2c0d5ff81..fda1030e2 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -149876,13 +149876,11 @@ function getCommandCacheFilePath() { return path6.join(getTemporaryDirectory(), COMMAND_CACHE_FILENAME); } function readCommandCacheFile() { - let contents; - try { - contents = fs6.readFileSync(getCommandCacheFilePath(), "utf8"); - } catch { + if (!fs6.existsSync(getCommandCacheFilePath())) { return {}; } try { + const contents = fs6.readFileSync(getCommandCacheFilePath(), "utf8"); const parsed = parseString(contents); if (isObject(parsed)) { return parsed; diff --git a/src/cache.ts b/src/cache.ts index a9fbbc47c..ca766bf74 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -47,13 +47,11 @@ function getCommandCacheFilePath(): string { * or otherwise unreadable file is treated as an empty cache. */ function readCommandCacheFile(): Record { - let contents: string; - try { - contents = fs.readFileSync(getCommandCacheFilePath(), "utf8"); - } catch { + if (!fs.existsSync(getCommandCacheFilePath())) { return {}; } try { + const contents = fs.readFileSync(getCommandCacheFilePath(), "utf8"); const parsed = json.parseString(contents); if (json.isObject(parsed)) { return parsed;