Skip to content

Commit

Permalink
Fix passing revalidateBefore option when calling cacheResponse to ens…
Browse files Browse the repository at this point in the history
…ure these go through background revalidation (#2342)
  • Loading branch information
jpreynat authored Jun 17, 2024
1 parent 3a4caf0 commit 22dc0d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/cache/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export function cache<Args extends any[], Result>(

if (savedEntry.meta.revalidatesAt && savedEntry.meta.revalidatesAt < Date.now()) {
// Revalidate in the background
waitUntil(revalidate(key, undefined, ...args));
await waitUntil(revalidate(key, undefined, ...args));
}

return savedEntry.data;
Expand Down
1 change: 1 addition & 0 deletions src/lib/cache/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function cacheResponse<Result, DefaultData = Result>(
return {
ttl: defaultEntry.ttl ?? parsed.ttl,
tags: [...(defaultEntry.tags ?? []), ...parsed.tags],
revalidateBefore: defaultEntry.revalidateBefore,
// @ts-ignore
data: defaultEntry.data ?? response.data,
};
Expand Down

0 comments on commit 22dc0d4

Please sign in to comment.