Skip to content

Commit a1f3399

Browse files
committed
Handle file-read errors as cache misses
This is particularly important for the first time that `getCachedCodeQlVersion` is invoked, as this cache file will not yet exist.
1 parent 5f8c44b commit a1f3399

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/util.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,10 +689,12 @@ export function getCachedCodeQlVersion(
689689
// Fall back to the value persisted by an earlier Actions step, if any. This is
690690
// best-effort: any malformed or mismatched value is ignored so that the caller
691691
// invokes `codeql version` instead.
692-
const serialized = fs.readFileSync(
693-
getPathToCodeQLVersionCacheFile(env),
694-
"utf8",
695-
);
692+
let serialized: string;
693+
try {
694+
serialized = fs.readFileSync(getPathToCodeQLVersionCacheFile(env), "utf8");
695+
} catch {
696+
return undefined;
697+
}
696698
let persisted: unknown;
697699
try {
698700
persisted = JSON.parse(serialized);

0 commit comments

Comments
 (0)