Skip to content

Commit 3c23a94

Browse files
authored
Merge pull request #47 from styxlab/fix-isr-file-cache
catch exception, if file cache cannot be written
2 parents 74a0fb8 + 7fc2a00 commit 3c23a94

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎lib/cache.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,9 @@ export function setCache(key: string | null, object: unknown): void {
3131
if (!makeDirectory(cacheRoot)) return
3232

3333
const filePath = path.join(cacheRoot, `${key}.txt`)
34-
fs.writeFileSync(filePath, JSON.stringify(object as JSON))
34+
try {
35+
fs.writeFileSync(filePath, JSON.stringify(object as JSON))
36+
} catch (error) {
37+
console.warn('Could not write to file cache. This is expected during ISR, but not during deploy.', error)
38+
}
3539
}

0 commit comments

Comments
 (0)