Skip to content

Commit

Permalink
Merge pull request #47 from styxlab/fix-isr-file-cache
Browse files Browse the repository at this point in the history
catch exception, if file cache cannot be written
  • Loading branch information
styxlab authored Feb 14, 2021
2 parents 74a0fb8 + 7fc2a00 commit 3c23a94
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ export function setCache(key: string | null, object: unknown): void {
if (!makeDirectory(cacheRoot)) return

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

1 comment on commit 3c23a94

@vercel
Copy link

@vercel vercel bot commented on 3c23a94 Feb 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.