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

Isar Inspector with multiple instances #104

Open
3 tasks done
FritzMatthaeus opened this issue Sep 12, 2024 · 3 comments
Open
3 tasks done

Isar Inspector with multiple instances #104

FritzMatthaeus opened this issue Sep 12, 2024 · 3 comments

Comments

@FritzMatthaeus
Copy link

FritzMatthaeus commented Sep 12, 2024

Steps to Reproduce

I do create multiple Isar Instances each with different schemas. When i open the isar inspector, i can see all schemas but only in first instance there ist data displayed. When switching instances the isar inspector is stuck to loading

Code sample

create a new flutter project with isar, path_provider and build_runner dependencies. Paste this code in main.dart, run the App and open the Isar Inspector Link. the Foo instance will show data, the Bar instance will show loading.

import 'package:flutter/material.dart';
import 'package:isar/isar.dart';
import 'package:path_provider/path_provider.dart';

part 'main.g.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final directory = await getApplicationDocumentsDirectory();

  final fooIsar =
      await Isar.open([FooSchema], directory: directory.path, name: "Foo");
  final barIsar =
      await Isar.open([BarSchema], directory: directory.path, name: "Bar");

  await fooIsar.writeTxn(() async {
    await fooIsar.foos.put(Foo(id: 1, name: "foo"));
  });
  await barIsar.writeTxn(() async {
    await barIsar.bars.put(Bar(id: 1, name: "bar"));
  });

  runApp(const MyApp());
}

@collection
class Bar {
  final Id id;
  final String name;
  Bar({
    required this.id,
    required this.name,
  });
}

@collection
class Foo {
  final Id id;
  final String name;
  Foo({
    required this.id,
    required this.name,
  });
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Isar Example'),
        ),
        body: const Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text('Isar Example'),
            ],
          ),
        ),
      ),
    );
  }
}

Details

  • Platform: Android 13, Samsung Galaxy A54, but also occured on other Android devices
  • Flutter version: 3.24.1
  • Isar version: 3.1.7

  • I searched for similar issues already
  • I filled the details section with the exact device model and version
  • I am able to provide a reproducible example
@FritzMatthaeus
Copy link
Author

I have been trying to debug this. Unfortunately i was not able to get the Isar Inspector running in Debug mode and connect to my Isar-Instance :( So i am depending on help. I could find out, that on changing the Isar Instance the following JS-Error is thrown:

Uncaught Error: ext.isar.executeQuery: (-32000) Server error
Null check operator used on a null value

i could trace it to this method in the isar inspector package connect_client.dart:

Future<Map<String, Object?>> executeQuery(ConnectQuery query) async {
    return _call<Map<String, Object?>>(
      ConnectAction.executeQuery,
      args: query.toJson(),
      timeout: kLongTimeout,
    );
  }

ConnectAction.executeQuery connects to the Isar Instance and seems to fail as the JS Error indicates.

If anyone feels competent to address this issue, i would be very grateful. As far is could research, this issue has been fixed for V4 by the original Author of the Isar Package. So there is a fix somewhere deep down in the Rust Core... but i have no clue how to track this.

Thanks and best regards,
Fritz

@stodevCoding
Copy link

@FritzMatthaeus Hi, I had a similar issue, but with a hot reload by pressing Shift + R, I do get the link to access the Isar Inspector, and it only works in Chrome.

@FritzMatthaeus
Copy link
Author

@FritzMatthaeus Hi, I had a similar issue, but with a hot reload by pressing Shift + R, I do get the link to access the Isar Inspector, and it only works in Chrome.

Thank you, but maybe my issue was not clear. I can open the inspector in chrome, but i cannot switch between my different Isar Instances. Only the first opened instance is accessible. See the code example.

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

No branches or pull requests

2 participants