Skip to content

Commit 9183a7b

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 9183a7b

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 13 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎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)