Hive: Hive doesn't work with Edge Browser (flutter web)

Created on 29 Jun 2020  路  10Comments  路  Source: hivedb/hive

Steps to Reproduce
add hive to flutter web project, and run
await Hive.openBox('box');
works well in chrome, but in edge, breaks my app (won't load)

Code sample
await Hive.openBox('box');

Version

  • Platform: Windows 10, Edge Browser
  • Flutter version: [鈭歖 Flutter (Channel beta, 1.19.0-4.2.pre, on Microsoft Windows [Version 10.0.19041.329], locale de-DE)
  • Hive version: 1.4.1
help wanted problem

Most helpful comment

@Constans can you please test latest commit 5d1742f /fix/issues/357?

Works like a charm after overriding the current with the patch:

dependency_overrides:
  hive:
    git:
      url: git://github.com/hivedb/hive.git
      ref: fix/issues/357
      path: hive
  hive_flutter:
    git:
      url: git://github.com/hivedb/hive.git
      ref: fix/issues/357
      path: hive_flutter
  hive_generator:
    git:
      url: git://github.com/hivedb/hive.git
      ref: fix/issues/357
      path: hive_generator

This was bugging me for almost 1 year. :))
I have a lot of dependencies in a project and I just assumed it will not work on Microsoft Edge. :)
Thanks for the fix!

All 10 comments

apparently the error is related to getAll not being available on Microsoft Edge indexeddb implementation

Thanks @Freundschaft maybe we can fix it using polyfill...

@Freundschaft could you let us know Edge version you're running?

Can someone check if #400 works or not?

Its the trident based edge version (non-chromium).

Can someone check if #400 works or not?

Before the fix I got this error (current hive version):
NoSuchMethodError: Object doesn't support property or method 'getAllKeys' (Error 438)
After the fix I get this error (patched version):
NoSuchMethodError: Unable to get property 'KU' of undefined or null reference (Error 5007)

The testing setup is simple. I just created a new Flutter project and added the hive packages in pubspec.yaml.
Then modified main.dart as follows:

import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';

void main() async {
  await Hive.initFlutter();
  await Hive.openBox('settings');
  runApp(MyApp());
}

In both cases (current version and "fixed" version) the app fails to work in Microsoft Edge 44.19041.423.0 EdgeHTML 18.19041
I hope it helps.

I've re-run my tests and it actually seems in both versions same error is thrown:

NoSuchMethodError: Object doesn't support property or method 'getAllKeys' (Error 438)

The difference is the line number where it happens due to the patch.

I've re-run my tests and it actually seems in both versions same error is thrown:

NoSuchMethodError: Object doesn't support property or method 'getAllKeys' (Error 438)

The difference is the line number where it happens due to the patch.

Thanks, I think it caused by the line below:

if (store.getAllKeys is Function ...

I have to use hasOwnProperty method. ref.

@Constans can you please test latest commit 5d1742f /fix/issues/357?

Works like a charm after overriding the current with the patch:

dependency_overrides:
  hive:
    git:
      url: git://github.com/hivedb/hive.git
      ref: fix/issues/357
      path: hive
  hive_flutter:
    git:
      url: git://github.com/hivedb/hive.git
      ref: fix/issues/357
      path: hive_flutter
  hive_generator:
    git:
      url: git://github.com/hivedb/hive.git
      ref: fix/issues/357
      path: hive_generator

This was bugging me for almost 1 year. :))
I have a lot of dependencies in a project and I just assumed it will not work on Microsoft Edge. :)
Thanks for the fix!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aminjoharinia picture aminjoharinia  路  3Comments

kaboc picture kaboc  路  3Comments

jamesdixon picture jamesdixon  路  3Comments

SergeShkurko picture SergeShkurko  路  4Comments

Hopheylalal picture Hopheylalal  路  4Comments