-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Hydrated bloc state lost after deploying updates to web app #4335
Comments
Hi @JakesMD 👋 Does the issue persist when you upgrade to the latest stable version of hydrated_bloc (v10.0.0)? |
Hi! Good point! I missed the update you released a couple hours ago. Will get back asap... |
I works! 🥳 Thanks! |
Sorry 🙈 I just released another update to my app and the state was lost again. |
Tomorrow I'll have a go at hosting the counter example app and seeing if I can reproduce the issue that way. That would prove whether this really is a hydrated_bloc issue. |
How are you deploying updates? Sorry for the inconvenience! |
Hi! Can confirm: this is reproducible with the counter example. You tend to lose state when you include a new package. Steps to reproduce
That works perfectly. The state is always persisted. Now do this:
Voila, your state was lost. Or at least parts of it. When I added flutter_confetti I lost the brightness, when I add signed_spacing_flex I lost all the state. I tested this on MacBook Safari and Android Chrome. |
@JakesMD thanks for the update and detailed reproduction steps! Are you able to share the Flutter version you're using? I'll try to reproduce shortly 👍 |
Stable 3.27.1 |
Hi! I've been playing around and have discovered some important points:
|
Thanks for all the context! I'm digging into this now 👍 |
I was able to reproduce and I was able to resolve this by changing my firebase hosting configuration to use: "public": "build/web", instead of "source": "." This way the firebase-deploy command doesn't actually run the flutter build step. Then I ran Let me know if that helps and apologies for the delayed response! |
Seems to be fixed 👍 It works when you make different changes to the app on every update (which will be 99% of the time). But when you revert changes it loads old state again. My firebase config was already set to After building with "headers": [
{
"source": "**",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=60"
}
]
}
] I've only tested this with the counter example and have yet to try it with the production app. |
Can you try unregistering the service worker manually? I need to dig into what the generated service worker is doing but I’d check if a brand new app/deployment has the same issues. |
Can you try the code here and see if anything changes? |
Description
Whenever I deploy an update to my web app, the bloc state is lost.
Steps To Reproduce
Expected Behavior
The state should persist no matter if push an update.
I'm guessing this is because the
HydratedStorage.webStorageDirectory
is just cache which gets deleted on an update. But I would expect the defaultwebStorageDirectory
to persist.Additional Context
I'm using hydrated bloc to persist the theme mode, language settings as well as recently viewed items.
The text was updated successfully, but these errors were encountered: