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

[BUG] FMTCStoreNotReady (FMTCStoreNotReady: The store ('TestStore') does not exist at this time, and is not ready. #108

Closed
4 tasks done
sikandernoori opened this issue Feb 27, 2023 · 6 comments
Labels
bug This issue reports broken functionality or another error invalid The reported bug cannot be reproduced, or the feature request is impossible or already exists

Comments

@sikandernoori
Copy link
Contributor

What is the bug?

Exception has occurred.
FMTCStoreNotReady (FMTCStoreNotReady: The store ('TestStore') does not exist at this time, and is not ready. Ensure that your application does not use the method that triggered this error unless it is sure that the store will exist at this point.)

What is the expected behaviour?

Store should Create successfully without exceptions.

How can we reproduce this issue?

Create Store in example App.

Do you have a potential solution?

Yes,

  Future<void> createAsync() async {
    if (ready) return;  // this is wrong as at this time store is not created.

    final db = await Isar.open(
      [DbStoreDescriptorSchema, DbTileSchema, DbMetadataSchema],
      name: _id.toString(),
      directory: _rootDirectory.path,
      maxSizeMiB: FMTC.instance.settings.databaseMaxSize,
      compactOnLaunch: FMTC.instance.settings.databaseCompactCondition,
      inspector: false,
    );
    await db.writeTxn(
      () => db.storeDescriptor.put(DbStoreDescriptor(name: _name)),
    );
    _registry.register(_id, db);
  }

Can you provide any other information?

No response

Platforms Affected

iOS

Severity

Minimum: Allows normal functioning

Frequency

Consistently: Always occurs at the same time and location

Requirements

@sikandernoori sikandernoori added bug This issue reports broken functionality or another error needs verification This needs to be verified/tested before fixes (or not) can be made labels Feb 27, 2023
sikandernoori pushed a commit to sikandernoori/flutter_map_tile_caching that referenced this issue Feb 27, 2023
@JaffaKetchup
Copy link
Owner

Hi @sikandernoori,

In this case, the code seems to be OK. If the store already exists (is ready), it shouldn't be recreated. However, this error does suggest an issue.

For reference, here's the ready code:

try {
  _registry(_name);
  return true;
  // ignore: avoid_catching_errors
} on FMTCStoreNotReady catch (e) {
  if (e._registered) rethrow;
  return false;
}

I can't reproduce with the example app. Can you take a screen recording, or make a minimal reproducible example please?

Many thanks.

@sikandernoori
Copy link
Contributor Author

@JaffaKetchup the issue is present in example App.

Steps to reproduce:

in example app root directory

  1. flutter create . (To create ios binaries)
  2. update pod file

replace

target 'Runner' do
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

with

target 'Runner' do
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  use_modular_headers!
end
  1. Then launch app on IOS device or simulator. (Error present on both in screenshot I am sharing emulator).
  2. Create a new store and hit save icon, you will be presented with error.

Moreover if you can see in _registry(name) call it's trying to look for store in _storeDatabases at create stage it will always return false because you are registering new db at the end of createAsync function.

  Future<void> createAsync() async {
    if (ready) return;

    final db = await Isar.open(
      [DbStoreDescriptorSchema, DbTileSchema, DbMetadataSchema],
      name: _id.toString(),
      directory: _rootDirectory.path,
      maxSizeMiB: FMTC.instance.settings.databaseMaxSize,
      compactOnLaunch: FMTC.instance.settings.databaseCompactCondition,
      inspector: false,
    );
    await db.writeTxn(
      () => db.storeDescriptor.put(DbStoreDescriptor(name: _name)),
    );
    _registry.register(_id, db); (This is where you are registering.)
  }

Screenshot 2023-02-28 at 12 48 24 AM

@sikandernoori
Copy link
Contributor Author

This screenshot should help more, check stack and variables values on left side.
Screenshot 2023-02-28 at 1 02 10 AM

@JaffaKetchup
Copy link
Owner

@sikandernoori Ah I see now.
Indeed, this error is thrown, but it is caught before it causes any issues: this is the way it's intended to function.
As you can see, the error never makes it to the console. Debu mode catches issues a little prematurely.
If you can "Run without Debugging", to ensure that the console only recives uncaught errors, you should be able to verify this behaviour.

@sikandernoori
Copy link
Contributor Author

Upto you, how you want to handle it.
In my opinion exception should not be thrown for creating store.

@JaffaKetchup
Copy link
Owner

@sikandernoori The exeception doesn't make it outside of my library, and it is caught and processed correctly. Within your app, you can 'pretend' it isn't thrown. Therefore, I don't think this is an issue.

@JaffaKetchup JaffaKetchup closed this as not planned Won't fix, can't repro, duplicate, stale Mar 1, 2023
@JaffaKetchup JaffaKetchup added invalid The reported bug cannot be reproduced, or the feature request is impossible or already exists and removed needs verification This needs to be verified/tested before fixes (or not) can be made labels Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue reports broken functionality or another error invalid The reported bug cannot be reproduced, or the feature request is impossible or already exists
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants