Skip to content

Commit 22dc0d4

Browse files
authored
Fix passing revalidateBefore option when calling cacheResponse to ensure these go through background revalidation (#2342)
1 parent 3a4caf0 commit 22dc0d4

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/lib/cache/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export function cache<Args extends any[], Result>(
202202

203203
if (savedEntry.meta.revalidatesAt && savedEntry.meta.revalidatesAt < Date.now()) {
204204
// Revalidate in the background
205-
waitUntil(revalidate(key, undefined, ...args));
205+
await waitUntil(revalidate(key, undefined, ...args));
206206
}
207207

208208
return savedEntry.data;

src/lib/cache/http.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export function cacheResponse<Result, DefaultData = Result>(
5050
return {
5151
ttl: defaultEntry.ttl ?? parsed.ttl,
5252
tags: [...(defaultEntry.tags ?? []), ...parsed.tags],
53+
revalidateBefore: defaultEntry.revalidateBefore,
5354
// @ts-ignore
5455
data: defaultEntry.data ?? response.data,
5556
};

0 commit comments

Comments
 (0)