-
Notifications
You must be signed in to change notification settings - Fork 409
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. (while opening a box) #192
Comments
Did you find a way to reproduce this error? It would be very helpful... |
I have been trying to without any luck so far. I initially thought it had something to do with my app state. Some context on what the app is doing:
On first load this process always works. If I hot or cold restart, kill the app, or send it to background and back to foreground, all of them have the tendency to produce the error on subsequent loads. I have noticed on some reloads, the debugger catches a "Recovering corrupt box" on the [Persons] box, but then I lose the existing associations between [Persons] and already generated [Messages]. Sometimes it does not display this message though, and simply fails to openBox(). I will keep trying other ways, but any suggestions on testing are appreciated. |
Hi, I am also having this bug but I did not find a way to reproduce it in a consistent way too.
|
same problem |
android
5 FlutterEngine create and main funcion in dart be called. |
I'm on 1.4.1+1 and see that the error comes from Frame readFrame({HiveCipher cipher, bool lazy = false, int frameOffset}) {
if (availableBytes < 4) return null;
var frameLength = readUint32();
if (frameLength < 8) {
throw HiveError(
'This should not happen. Please open an issue on GitHub.');
}
if (availableBytes < frameLength - 4) return null; In my scenario, While I'm unsure of how to reproduce this, I hope what I provided helps. @leisim Does anything stand out to you? Is it a problem that _bufferLimit == _offset? Also, fwiw,
|
@leisim Is it safe to say I need to just wait for the Rust implementation? |
I think the issue is solved for me after restructuring some of my reading/writing to be synchronous. For me, it was a matter of using |
I also needed to delete my old box and start a new one, because I think it was corrupt. |
@stevenspiel @leisim I also have this. |
After checking the debugger, when it reads my first value via the Also, could you please explain how |
Update I modified your @pragma('vm:prefer-inline')
@pragma('dart2js:tryInline')
void _requireBytes(int bytes) {
print("OFFSET: $_offset");
print("BYTES: $bytes");
print("BUFFER LIMIT: $_bufferLimit");
print("\n\n$_offset + $bytes > $_bufferLimit IS ${_offset + bytes > _bufferLimit}");
if (_offset + bytes > _bufferLimit) {
throw RangeError('Not enough bytes available.');
}
} Here is the last print statement right before it throws the exception:
EXCEPTION
|
I am also having this issue and can't find how to fix, also related to |
@leisim @themisir any updates on this? I ran into this issue multiple times. But this seems to be arbitrary to me. I couldn't find a reproducible sample code. But AFAIK, this once happened when I tried to open a box and immediately closing it (and around 5-6 times of HOT RESTARTING the app). That corrupted my whole box (also note that I couldn't again reproduce this). I have fear that whether this would happen in one of my production apps. You can see that the same issue is mentioned multiple times. My request is, please take a look at this issue as this seems to be very critical 🙏 |
Duplicate of #263 |
I did not noticed this issue was opened first, let's discuss about the issue on #263 |
Please someone help me solve this issue, Our company app is going to production soon. |
Could you share hive code you're using? We don't know exact reason for the issue currently. But if you have the code that reproduces this error it might help us to know what's going wrong. I would check your code in a private session if it would be cool to you, I just want to know what's wrong to solve this issue which is active for months. |
|
After upgrading to flutter 2 this started to happen again. I wasn't using Flutter 2 |
It has helped.. |
Hi All, We are facing the same issue. i.e Unhandled Exception: HiveError: This should not happen. Please open an issue on GitHub. May I propose the following changes in the implementation so that crash recovery can be leveraged? Proposed changes:Change 1. Introduce a new Error specific to Box corruption that extends HiveError and this will have a field to set the offset of the invalid frame, and the value for this should be the same as recoveryOffset in StorageBackendVm class HiveBoxCorruptionError extends HiveError { // offSet of the frame that caused the error /// Create a new Hive error (internal) Change 2. Changes in "StorageBackendVm" to catch HiveBoxCorruptionError and make use of the offset try {
Please let me know your thoughts? Change 3: Let BinaryReaderImpl throw HiveBoxCorruptionError when frameLength is < 8 etc.. Note: Please don't give too much attention to the syntax. I hope the core idea is clear. |
@yakubmoris what did you end up doing? |
We get this issue as well. How can we at least know the name of the corrupted box? |
Error
HiveError: This should not happen. Please open an issue on GitHub.
Steps to Reproduce
On app start-up I have a function to retrieve persons HiveObjects that are stored:
Error is immediately seen on this line. The app runs a few times without issue, then this popped up suddenly on a subsequent run.
Code sample
Version
The text was updated successfully, but these errors were encountered: