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

HiveError: This should not happen. #848

Closed
ozozozd opened this issue Nov 30, 2021 · 3 comments
Closed

HiveError: This should not happen. #848

ozozozd opened this issue Nov 30, 2021 · 3 comments
Labels
problem An unconfirmed bug.

Comments

@ozozozd
Copy link

ozozozd commented Nov 30, 2021

Steps to Reproduce
Attempting to open a LazyBox and await the result.

Code sample

aLazyBox = await Hive.openLazyBox('alazybox');

Version

  • Platform: Android
  • Flutter version: >=2.11.0 <3.0.0
  • Hive version: ^2.0.4

Stack Trace

E/flutter ( 5420):
E/flutter ( 5420): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: HiveError: This should not happen. Please open an issue on GitHub.
E/flutter ( 5420): #0      BinaryReaderImpl.readFrame
package:hive/…/binary/binary_reader_impl.dart:250
E/flutter ( 5420): #1      _KeyReader.readKeys
package:hive/…/io/frame_io_helper.dart:73
E/flutter ( 5420): <asynchronous suspension>
E/flutter ( 5420): #2      FrameIoHelper.keysFromFile
package:hive/…/io/frame_io_helper.dart:32
E/flutter ( 5420): <asynchronous suspension>
E/flutter ( 5420): #3      StorageBackendVm.initialize
package:hive/…/vm/storage_backend_vm.dart:88
E/flutter ( 5420): <asynchronous suspension>
E/flutter ( 5420): #4      HiveImpl._openBox
package:hive/src/hive_impl.dart:116
E/flutter ( 5420): <asynchronous suspension>
E/flutter ( 5420): #5      HiveImpl.openLazyBox
package:hive/src/hive_impl.dart:162
E/flutter ( 5420): <asynchronous suspension>

flutter doctor -v (sensitive info redacted or lines removed entirely)

[✓] Flutter (Channel stable, 2.5.1, on Mac OS X 10.15.6 19G73 darwin-x64, locale en-US)
    • Flutter version 2.5.1 at /Users/oz/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffb2ecea52 (2 months ago), 2021-09-17 15:26:33 -0400
    • Engine revision b3af521a05
    • Dart version 2.14.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at <redacted path>
    • Platform android-31, build-tools 31.0.0
    • Java binary at: <redacted path>
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at <redacted path>
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at <redacted path>

[✓] Android Studio (version 2020.3)
    • Android Studio at <redacted path>
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.62.0)
    • VS Code at <redacted path>
    • Flutter extension version 3.28.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • Mac OS X 10.15.6 19G73 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome <redacted IP>

• No issues found!
@ozozozd ozozozd added the problem An unconfirmed bug. label Nov 30, 2021
@huycn
Copy link

huycn commented Nov 30, 2021

I get the same error, in my case, it's not lazy box, just a regular final box = await Hive.openBox<DateTime>("appcache");

Note also that this doesn't always happen. In my case it works most of time, and error happens when the app is put in the background, and then later another instance of same Activity is created (i.e. two instances exist at the same time). Even in this scenario, it doesn't happen all the time. But once it happens, the error keeps come up every time I try openBox() with same name.

logcat:

I/flutter ( 9395): HiveError: This should not happen. Please open an issue on GitHub.
I/flutter ( 9395): #0      BinaryReaderImpl.readFrame (package:hive/src/binary/binary_reader_impl.dart:250:7)
I/flutter ( 9395): #1      FrameHelper.framesFromBytes (package:hive/src/binary/frame_helper.dart:21:26)
I/flutter ( 9395): #2      FrameIoHelper.framesFromFile (package:hive/src/io/frame_io_helper.dart:42:12)
I/flutter ( 9395): <asynchronous suspension>
I/flutter ( 9395): #3      StorageBackendVm.initialize (package:hive/src/backend/vm/storage_backend_vm.dart:86:11)
I/flutter ( 9395): <asynchronous suspension>
I/flutter ( 9395): #4      HiveImpl._openBox (package:hive/src/hive_impl.dart:116:9)
I/flutter ( 9395): <asynchronous suspension>
I/flutter ( 9395): #5      HiveImpl.openBox (package:hive/src/hive_impl.dart:145:12)
I/flutter ( 9395): <asynchronous suspension>
I/flutter ( 9395): #6      [My code...]

flutter doctor -v

[√] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version 10.0.22000.348], locale en-US)
    • Flutter version 2.5.3 at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (7 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\user\AppData\Local\Android\Sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_SDK_ROOT = C:\Users\user\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Users\user\AppData\Local\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[√] VS Code (version 1.62.3)
    • VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (3 available)
    • SAMSUNG SM G891A (mobile) •  android-arm64  • Android 8.0.0 (API 26)
    • Chrome (web)              • chrome             • web-javascript • Google Chrome 96.0.4664.45
    • Edge (web)                • edge               • web-javascript • Microsoft Edge 96.0.1054.34

• No issues found!

@WatchDogsDev
Copy link

Same here when opening box multiple times (throws error on close or deleteFromDisk)

@themisir
Copy link
Contributor

Closed with #914.

Please upgrade to hive v2.0.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem An unconfirmed bug.
Projects
None yet
Development

No branches or pull requests

4 participants