Skip to content

Commit

Permalink
fix(cache): call event.waitUntil on main resolver when expired
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 19, 2023
1 parent 454a920 commit 421d625
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/runtime/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ export function defineCachedFunction<T, ArgsT extends unknown[] = unknown[]>(

const _resolvePromise = expired ? _resolve() : Promise.resolve();

if (expired && event && event.waitUntil) {
event.waitUntil(_resolvePromise);
}

if (opts.swr && entry.value) {
// eslint-disable-next-line no-console
_resolvePromise.catch((error) => {
Expand Down

0 comments on commit 421d625

Please sign in to comment.