-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Cache.clear() doesn't work #13791
Comments
Hello, @lwang-79 👋. Can you clarify if you're experiencing this in Dev Mode? It's possible this behavior is due to how React's development mode will invoke the useEffect hook twice. It doesn't look like you're running a "cleanup function" that would help with this, so can you see if the following changes the behavior: useEffect(() => {
Cache.setItem("test", "test")
const timer = setTimeout(() => {
Cache.clear().then(() => {
console.log("cleared")
})
.catch(e => {
console.log("error", e)
})
}, 2000)
// Cleanup function
return () => {
clearTimeout(timer)
}
}, []); Alternatively, you could test this in production mode (rather than development mode) and it should also make the |
Hi @cwomack, thank you for checking this issue. I have verified that it's not due to the React restrict mode.
|
@lwang-79, appreciate the quick follow up. After testing this further on our side, we've confirmed there is a bug in v6 of Amplify with Thank you for opening this and helping us identify the bug! We'll update this issue with progress as it's made. |
@lwang-79 and anyone else following this issue, a fix for this was released in v6.6.6 of Amplify. Please upgrade to that (or the latest v6.6.7) and let us know if this issue is resolved! Thanks. |
@lwang-79 and anyone following this issue, this should now be resolved as of v6.8.1. Could you please upgrade to the latest version and confirm? |
Thank you @cwomack, I have tested and it's working now. |
Thanks for the confirmation, @lwang-79. Glad you're unblocked and we'll close this issue out as resolved then. |
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Cache
Amplify Version
v6
Amplify Categories
Not applicable
Backend
None
Environment information
Describe the bug
The Cache.clear() API doesn't work, the cache items are not removed from local storage after this API is called.
Cache.removeItem()
API works but need a quick way to remove all cache items after user log out.Expected behavior
All cache items created by Amplify Cache util can be removed.
Reproduction steps
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: