Fix passing revalidateBefore option when calling cacheResponse to ensure these go through background revalidation (#2342)

This commit is contained in:
Johan Preynat
2024-06-17 17:16:12 +02:00
committed by GitHub
parent 3a4caf062c
commit 22dc0d4ff5
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -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;
+1
View File
@@ -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,
};