-
Notifications
You must be signed in to change notification settings - Fork 133
Low level error upon QueryBuilder.watch(triggerImmediaterly: true) #343
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
Comments
Can you try to create a new So replace above with something like: return store.box<Search>().query().
.watch(triggerImmediately: true)
.map((query) => query.find()); We should check why there is no proper error message that the builder is already closed. |
I did indeed work with the fix above. I guess marking it as final and putting debugPrints inbetween made flutter optimize it out as some kind of constant-ish value (placing them right beside each other works, even with the queryBuilder marked as final) |
So, we should handle this error more gracefully, I guess? @greenrobot-team |
@h7x4ABk3g This has nothing to do with Flutter optimization. I'll annotate your code, maybe that makes it more clear: debugPrint('Creating queryBuilder');
final QueryBuilder<Search> queryBuilder = store.box<Search>().query();
debugPrint('Items: ' +
queryBuilder
.build() // <-- This builds a Query and closes the QueryBuilder.
.find()
.map((e) => e.searchTerm)
.toList()
.toString());
debugPrint('Creating stream');
return queryBuilder
.watch(triggerImmediately: true) // <-- tries to reuse already closed QueryBuilder
.map((query) => query.find()); Or put differently: you can re-use a |
Thank you, I didn't notice! That makes a lot of sense. |
Alright, closing this then. |
Parts of the native library produces a low level error upon executing
queryBuilder.watch(triggerImmediately: true)
.Basic info:
^1.3.0
Linux 5.10.79-1-MANJARO
Pixel 3 API 30 (emulator)
andSamsung S8 Plus (SM-G855F) API 28
flutter deps --no-dev
flutter doctor -v
Steps to reproduce
Replace
main.dart
andpubspec.yaml
with the code below.Connect a phone/emulator and run the app:
Expected behavior
I expected this stream
to be a stream that would yield a list of the contents of
box<Search>
. This would yield a new list every time the contents were updated.Unfortunately, the code crashes at the return statement. See the debugPrints in the embedded
main.dart
and the debug console output.Code
pubspec.yaml
main.dart
Logs, stack traces
VSCode Debug Console Output
(The output for the Samsung device is virtually the same)
Additional context
This is a (somewhat) minimal example extracted from a larger app. I was working on the larger app at around August 2021, and at that time the code worked properly. I might be wrong, but I'm pretty sure this is a bug that has been introduced since that time.
I found an issue with the same segfault code in this project #191, but the person seemed to be using a completely different library with a similar name. However, the question that was answered over there might have similarities to this?
The text was updated successfully, but these errors were encountered: