Skip to content

Commit

Permalink
fix: return stale cache when swr is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Mar 8, 2023
1 parent a322405 commit 58dd975
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/runtime/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function defineCachedFunction<T = any>(
const _resolve = async () => {
const isPending = pending[key];
if (!isPending) {
if (entry.value !== undefined && (opts.staleMaxAge || 0) >= 0) {
if (entry.value !== undefined && (opts.staleMaxAge || 0) >= 0 && opts.swr === false) {
// Remove cached entry to prevent using expired cache on concurrent requests
entry.value = undefined;
entry.integrity = undefined;
Expand Down

0 comments on commit 58dd975

Please sign in to comment.