-
Notifications
You must be signed in to change notification settings - Fork 88
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: clear cacheVersions on flushCache #807
Conversation
src/index.ts
Outdated
@@ -722,6 +728,7 @@ class Storyblok { | |||
|
|||
public async flushCache(): Promise<this> { | |||
await this.cacheProvider().flush() | |||
this.clearCacheVersion(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could remove the ;
this.clearCacheVersion(); | |
this.clearCacheVersion() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested using the script and ran other tests and it seems to be working well.
🎉 This PR is included in version 6.7.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR fixes the issue number 2 from #806. The issue is intermittent because of a combination of factors, but in some cases it will result in the JS Client serving cached content even after flushing the cache, because the
flushCache
method clears the cache but it doesn't clear the cachedcv
value used for performing requests.Pull request type
How to test this PR
In order to simulate a case that would be affected by this bug, you can run the following script. To get the accessToken, spaceId, storyId and get added to the space for testing, please DM me. Of course you can setup your own space and script, but with this one it will be quick :-)
If you run it on the main branch, you will always get the same values for all the 3 requests. With this branch you will get the current value after flushing the cache.
What is the new behavior?
The
cv
value is set to0
when theflushCache
method is executed.Other information