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

Bad State No element when putting a Map into a Box #50

Closed
ThinkDigitalSoftware opened this issue Sep 14, 2019 · 12 comments
Closed

Bad State No element when putting a Map into a Box #50

ThinkDigitalSoftware opened this issue Sep 14, 2019 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@ThinkDigitalSoftware
Copy link

ThinkDigitalSoftware commented Sep 14, 2019

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

@ThinkDigitalSoftware ThinkDigitalSoftware added the bug Something isn't working label Sep 14, 2019
@ThinkDigitalSoftware ThinkDigitalSoftware changed the title Bad State No element when writing a Map Bad State No element when putting a Map Sep 14, 2019
@ThinkDigitalSoftware ThinkDigitalSoftware changed the title Bad State No element when putting a Map Bad State No element when putting a Map into a Box Sep 14, 2019
@simc
Copy link
Member

simc commented Sep 15, 2019

On which device does this error happen?

@simc
Copy link
Member

simc commented Sep 15, 2019

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 👍

@ThinkDigitalSoftware
Copy link
Author

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

@ThinkDigitalSoftware
Copy link
Author

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

@simc
Copy link
Member

simc commented Sep 16, 2019

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

That would be really helpful...

@ThinkDigitalSoftware
Copy link
Author

ThinkDigitalSoftware commented Sep 16, 2019

Here ya go.
ThinkDigitalSoftware/tavern@672e70d

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

@simc
Copy link
Member

simc commented Sep 16, 2019

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

@simc
Copy link
Member

simc commented Oct 2, 2019

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

@simc simc closed this as completed Oct 2, 2019
@ThinkDigitalSoftware
Copy link
Author

Thanks!

@ThinkDigitalSoftware
Copy link
Author

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

@simc
Copy link
Member

simc commented Oct 3, 2019

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

@vamsireddytalla
Copy link

when i try to write this code in flutter using hive with latest versions.

Product? product = _products.firstWhere((product) => product?.id == productId, orElse: () => null);
if (product != null) {
isExist = true;
}

i am getting error like this

Unhandled Exception: type '() => Null' is not a subtype of type '(() => ApiLogs)?' of 'orElse'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants