Hive: Bad State No element when putting a Map into a Box

Created on 15 Sep 2019  Â·  11Comments  Â·  Source: hivedb/hive

Stacktrace

Unhandled Exception: Bad state: No element
#0      ListQueue.removeFirst (dart:collection/queue.dart:729:25)
#1      Keystore.cancelTransaction (package:hive/src/box/keystore.dart:143:33)
#2      BoxImpl._writeFrame (package:hive/src/box/box_impl.dart:74:16)
<asynchronous suspension>
#3      BoxImpl.put (package:hive/src/box/box_impl.dart:57:12)
#4      Cache.setLastFetched (package:tavern/src/cache.dart:48:11)
#5      Cache.[]= (package:tavern/src/cache.dart:93:5)
#6      MapMixin.addAll (dart:collection/maps.dart:122:11)
#7      PageRepository.get (package:tavern/screens/home/home_bloc.dart:169:21)
#8      _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#9      _rootRunUnary (dart:async/zone.dart:1132:38)
#10     _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#11     _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#12     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)<…>

Steps to Reproduce
Not sure how. It only happens when the app starts, a box is opened and written to quickly. If I put a breakpoint and it pauses, then when it resumes, the error doesn't show up
Code sample
link to repo: https://github.com/ThinkDigitalSoftware/tavern
Image of the frame, just in case you can grab something from it
Screen Shot 2019-09-14 at 3 05 12 PM

Version

  • Flutter 1.10.1 • channel dev • https://github.com/flutter/flutter.git
  • Framework • revision ce45c2d3e6 (8 days ago) • 2019-09-06 20:11:41 -0400
  • Engine • revision b9ce2500d9
  • Tools • Dart 2.5.0 (build 2.5.0-dev.4.0 be66176534)
  • Hive version: 1.0.0
bug

All 11 comments

On which device does this error happen?

What I believe happens: Hive can for some reason not write to the box file (not necessarily a bug in Hive). It then reverts the key transaction to be in sync with the disk. This operation fails (certainly a bug). I'll try to find the reason.

Thanks for reporting. If you find any more information or even a way to reproduce this, please share it here :+1:

Thanks. This is being tested on an iOS simulator. It was consistent in my code, which is available at the repo I linked to , however, I removed the class I was using it in because it wasn't necessary for the app. I can point you to the previous commit if you'd really like to see it in action

Thanks. This is being tested on an iOS simulator. It was consistent in my code, which is available at the repo I linked to , however, I removed the class I was using it in because it wasn't necessary for the app. I can point you to the previous commit if you'd really like to see it in action

I can point you to the previous commit if you'd really like to see it in action

That would be really helpful...

Here ya go.
https://github.com/ThinkDigitalSoftware/tavern/commit/672e70d9ff6807ed082b945ee1fff85e682aa115

If I'm being too vague, let me know please. I'll help where I can

Thanks for your help, I'll try to reproduce it...

Sorry this was a bigger problem but it is now fixed with 1.1.0-beta.

Thanks!

@leisim Do we need to clone the repo to get this fix?

No you can use version 1.1.0-beta from pub.dev

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rupamking1 picture rupamking1  Â·  3Comments

jamesdixon picture jamesdixon  Â·  3Comments

aminjoharinia picture aminjoharinia  Â·  3Comments

Ferdzzzzzzzz picture Ferdzzzzzzzz  Â·  3Comments

juandiago picture juandiago  Â·  4Comments