hive icon indicating copy to clipboard operation
hive copied to clipboard

HiveError: Could not read value from box. Maybe your box is corrupted.

Open AndreHaueisen opened this issue 1 year ago • 7 comments

Hi. I'm getting this exception in production, but I can't figure out why it is happening and I haven't been able to reproduce it in dev. Do you have any insights into when this exception is thrown?

Screenshot 2023-06-02 at 10 02 33

It appears it happens when line 49 tries to access my box.

Screenshot 2023-06-02 at 10 07 16

I'd appreciate any tips you think might be relevant. I've asked the same question to the dio_cache_manager dev, and he thinks you guys might be able to help.

AndreHaueisen avatar Jun 02 '23 13:06 AndreHaueisen

I am also getting similar error while running my test in github ci windows box:

Failed to put vel: [[1691177347124887552]NO₂, [1691177349456920577]NO₂, [1691177350023151616]NO₂] pair in $nitrite_index|Employee|employeeNote.text|Fulltext
 #0      StorageBackendVm.readValue.<anonymous closure> (package:hive/src/backend/vm/storage_backend_vm.dart:114:9)
 <asynchronous suspension>
 #1      StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:124:15)
 <asynchronous suspension>
 
 Caused by: HiveError: Could not read value from box. Maybe your box is corrupted.

I am using LazyBox to store my data.

This error is intermittent and it is happening only in github ci windows box. In my Windows (x64) dev machine, I am not seeing this issue, also neither in my Ubuntu (x64) or MacOS (m2) machine. Hope this info helps.

anidotnet avatar Aug 15 '23 05:08 anidotnet

I'm also encountering this same issue, using dio_cache_manager with flutter_map. Did you ever solve this?

mdanics avatar Oct 28 '23 08:10 mdanics

We are also seeing this error, here is our stacktrace:

HiveError: HiveError: Could not read value from box. Maybe your box is corrupted.
  File "storage_backend_vm.dart", line 114, in StorageBackendVm.readValue.<fn>
  File "<asynchronous suspension>"
  File "future_impl.dart", line 41, in _AsyncCompleter.complete
  File "<asynchronous suspension>"
  File "lazy_box_impl.dart", line 32, in LazyBoxImpl.get
  File "<asynchronous suspension>"
  File "dio_cache_interceptor.dart", line 186, in DioCacheInterceptor._loadCacheResponse
  File "<asynchronous suspension>"
  File "dio_cache_interceptor.dart", line 47, in DioCacheInterceptor.onRequest

We also use Hive in other parts of our app but the stacktrace is always from the dio_cache_interceptor

flodaniel avatar Mar 13 '24 16:03 flodaniel

same here we only got the issue while using dio_cache_interceptor and also is always image dio_cache_interceptor_hive_store.dart

oscarshaitan avatar May 07 '24 07:05 oscarshaitan

I will now try to create the HiveCacheStore from dio_cache_interceptor soon as the app starts. Previously we only created it when we needed it and my theory is that the HiveCacheStore clean() method is still running while it it is already being used, leading to this error as the value is removed and accessed at the same time.

flodaniel avatar Aug 07 '24 07:08 flodaniel

I have the same issue reported via sentry many times

hive: 2.2.3 dio_cache_interceptor_hive_store:3.2.2

Screenshot 2024-08-14 at 20 59 59

ibraheemalayan avatar Aug 14 '24 18:08 ibraheemalayan

Update:

I got the same bug after deleting app, reinstalling it.

ibraheemalayan avatar Aug 14 '24 19:08 ibraheemalayan