Skip to content

Unhandled Exception: Bad state: failed to create store: 10001 Cannot open store: another store is still open using the same path: #433

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

Closed
akshay-kapase opened this issue Jun 5, 2022 · 6 comments
Labels
more info required Needs more info to become actionable. Auto-closed if no response.

Comments

@akshay-kapase
Copy link

akshay-kapase commented Jun 5, 2022

Basic info (please complete the following information):

  • ObjectBox version: 1.5.0
  • Flutter/Dart SDK: Flutter 2.10.5 • channel stable Dart 2.16.2 • DevTools 2.9.2
  • Null-safety enabled: [yes]
  • Reproducibility: occurs every time I click on the notification
  • OS: All versions
  • Device/Emulator: Pixel 3a Api 32

Steps to reproduce

  1. I'm using moengage library for push notifications. When the notification is clicked the main function is called.
  2. Notification is clicked while the app is running, then after that store is getting as null and if "await openStore" is called its causing an error showing "Store is already open"

Expected behavior

Store should not be null.

Code

If applicable, add code to help explain your problem.

  • Include your pubspec.yaml.
    objectbox: 1.5.0
    objectbox_flutter_libs: 1.5.0

Logs, stack traces

Unhandled Exception: Bad state: failed to create store: 10001 Cannot open store: another store is still open using the same path:

@akshay-kapase akshay-kapase added the bug Something isn't working label Jun 5, 2022
@greenrobot-team
Copy link
Member

Modify your code so it ensures only a single instance of a Store exists while the app is running.

Our examples do this by initializing Store in the apps main function, which should only ever get called once IIRC.

Feel free to share a code example if you think we can improve the behavior or our code examples of ObjectBox.

@greenrobot-team greenrobot-team added more info required Needs more info to become actionable. Auto-closed if no response. and removed bug Something isn't working labels Jun 13, 2022
@github-actions
Copy link

github-actions bot commented Jul 5, 2022

Without additional information, we are unfortunately not sure how to resolve this issue. Therefore this issue has been automatically closed. Feel free to comment with additional details and we can re-open this issue.

@github-actions github-actions bot closed this as completed Jul 5, 2022
@venky9885
Copy link

i am also facing same issue in windows application making flutter in object box version 1.6.0

@venky9885
Copy link

[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: Bad state: failed to create store: 10001 Cannot open store: another store is still open using the same path: "C:\Users\venky\Documents\objectbox"
#0 ObjectBoxNativeError.throwMapped (package:objectbox/src/native/bindings/helpers.dart:66)
#1 throwLatestNativeError (package:objectbox/src/native/bindings/helpers.dart:50)
#2 checkObxPtr (package:objectbox/src/native/bindings/helpers.dart:32)
#3 Store._checkStorePointer (package:objectbox/src/native/store.dart:309)
#4 new Store (package:objectbox/src/native/store.dart:150)
#5 openStore (package:soft_desk/objectbox.g.dart:180)

#6 main (package:soft_desk/main.dart:97)

These are the logs

@venky9885
Copy link

i tried changing versions from 1.2.0 to 1.6.0 But there is no use
i am making windows application using flutter

@greenrobot-team
Copy link
Member

greenrobot-team commented Jul 11, 2022

@venky9885 Are you sure the code that opens the store is only called once? You can use Store.isOpen(directory) to add a simple check.

Edit: if opening multiple times is by design, e.g. if using multiple Flutter Engines, then see this related issue: #436

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more info required Needs more info to become actionable. Auto-closed if no response.
Projects
None yet
Development

No branches or pull requests

3 participants