Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cache): use stale value by default when swr is enabled #1038

Merged
merged 2 commits into from
Mar 8, 2023
Merged

Conversation

atinux
Copy link
Collaborator

@atinux atinux commented Mar 8, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

To be properly tested.

So far, when swr: true, we should return the stale data for all incoming request until the cache is updated in background.

Also, I am not sure to understand the (opts.staleMaxAge || 0) >= 0 condition here.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Merging #1038 (97e8e28) into main (a322405) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1038   +/-   ##
=======================================
  Coverage   67.59%   67.59%           
=======================================
  Files          62       62           
  Lines        6259     6259           
  Branches      707      707           
=======================================
  Hits         4231     4231           
  Misses       2015     2015           
  Partials       13       13           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@pi0
Copy link
Member

pi0 commented Mar 8, 2023

Thanks for the PR.

staleMaxAge is the time when we should stop responding to stale responses.

#857 supported -1 value as a quick solution to allow setting stale time to inifnity.

I think we can set it as default.

@pi0 pi0 changed the title fix: return stale cache when swr is enabled fix(cache): use stale value by default when swr is enabled Mar 8, 2023
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good hotfix to be back to previous behavior until handling staleMaxAge properly

@pi0 pi0 merged commit 788cc80 into main Mar 8, 2023
@pi0 pi0 deleted the fix/swr branch March 8, 2023 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants