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: Adding a new hydrated cubit to an app that already has state causes errors from Hive. #3243

Closed
zmoshansky opened this issue Feb 22, 2022 · 3 comments
Assignees
Labels
bug Something isn't working pkg:hydrated_bloc This issue is related to the hydrated_bloc package question Further information is requested

Comments

@zmoshansky
Copy link

zmoshansky commented Feb 22, 2022

Description
I've added a new hydratedCubit to an app (Android), that has already persisted data, and upon calling HydratedStorage.build it errors. The cubit I added has a single required field String id, and is built with freezed (AFAICT, shouldn't matter). When running the app inside a fresh web-browser profile (storage is clear) everything works fine.

I'm unsure if this is a Hive issue, or an issue with HydratedBloc's use of Hive.

E[/flutter]() (21463): [ERROR:flutter[/lib/ui/ui_dart_state.cc]()(209)] Unhandled Exception: HiveError: This should not happen. Please open an issue on GitHub.
E[/flutter]() (21463): #0      BinaryReaderImpl.readFrame
package:hive/…/binary/binary_reader_impl.dart:250
E[/flutter]() (21463): #1      FrameHelper.framesFromBytes
package:hive/…/binary/frame_helper.dart:21
E[/flutter]() (21463): #2      FrameIoHelper.framesFromFile
package:hive/…/io/frame_io_helper.dart:42
E[/flutter]() (21463): <asynchronous suspension>
E[/flutter]() (21463): #3      StorageBackendVm.initialize
package:hive/…/vm/storage_backend_vm.dart:86
E[/flutter]() (21463): <asynchronous suspension>
E[/flutter]() (21463): #4      HiveImpl._openBox
package:hive/src/hive_impl.dart:111
E[/flutter]() (21463): <asynchronous suspension>
E[/flutter]() (21463): #5      HiveImpl.openBox
package:hive/src/hive_impl.dart:139
E[/flutter]() (21463): <asynchronous suspension>
E[/flutter]() (21463): #6      HydratedStorage.build.<anonymous closure>
package:hydrated_bloc/src/hydrated_storage.dart:101
E[/flutter]() (21463): <asynchronous suspension>
E[/flutter]() (21463): #7      BasicLock.synchronized
package:synchronized/src/basic_lock.dart:33
E[/flutter]() (21463): <asynchronous suspension>
E[/flutter]() (21463): #8      main
package:foo/main.dart:24
E[/flutter]() (21463): <asynchronous suspension>

Steps To Reproduce
1.) Create an App with a hydratedCubit
2.) Launch app and have cubit save state
3.) Add a new hydratedCubit to the app
4.) Calling HydratedStorage.build it errors from Hive.

Expected Behavior
This should just work, or cause some error in my deserialization code.

Additional Context
When running the app inside a fresh web-browser profile (storage is clear) everything works fine. This also relates to #2613
w

@zmoshansky zmoshansky added the bug Something isn't working label Feb 22, 2022
@zmoshansky zmoshansky changed the title fix: Adding a new hydrated cubit to an app that already causes errors from Hive. fix: Adding a new hydrated cubit to an app that already has state causes errors from Hive. Feb 22, 2022
@zmoshansky
Copy link
Author

After clearing app storage, everything works properly on Android... However, this is obviously not a workable solution for a production app.

@felangel felangel added the pkg:hydrated_bloc This issue is related to the hydrated_bloc package label Feb 23, 2022
@felangel
Copy link
Owner

Hi @zmoshansky 👋
Thanks for opening an issue!

Are you able to provide a link to a minimal reproduction sample? Thanks!

@felangel felangel added waiting for response Waiting for follow up question Further information is requested labels Feb 23, 2022
@zmoshansky
Copy link
Author

I'm going to close this as I strongly suspect this underlying issue is the root cause of the issue (Many reported bugs around corruption).

isar/hive#263

@felangel felangel removed the waiting for response Waiting for follow up label Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:hydrated_bloc This issue is related to the hydrated_bloc package question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants