(Another) mysterious MissingAPI error #1411
Replies: 7 comments
-
Ok, thanks! |
Beta Was this translation helpful? Give feedback.
-
This is because RangeSet class depends on indexedDB.cmp(). Could put the RangeSet constructor on the db instance and generate one per db instance (as doing with Transaction, Table, Collection etc). I am though very tempted to do a breaking change here and stop accepting the {indexedDB, IDBKeyRange} as options because static methods like Dexie.delete() would anyway need to be configured by setting the static deps in Dexie.dependencies globally. import indexedDB from "fake-indexeddb"; // 3.1.3
import IDBKeyRange from "fake-indexeddb/lib/FDBKeyRange.js";
// Configure DOM dependencies on static prop
Dexie.dependencies.indexedDB = indexedDB;
Dexie.dependencies.IDBKeyRange = IDBKeyRange;
// ...is needed before calling static method Dexie.delete():
await Dexie.delete("MyDatabase"); Might need to bump version to 4.0 if so. The thing is - is it worth it having a lot of plumping code just to support per-instance IDBFactory? Maybe it is? Thoughts? |
Beta Was this translation helpful? Give feedback.
-
I can only think of one use case for per-instance configuration: parallel unit tests. But I think that can be approximated by having the one global dependency and using different database names for each dexie instance. I’ll try it and get back to you. From a marketing/social perspective, having an excuse to launch Dexie 4.0 with dexie-cloud 1.0 might help garner some attention. 😉 |
Beta Was this translation helpful? Give feedback.
-
Confirmed: copy-pasting your dependency setup code and appending a |
Beta Was this translation helpful? Give feedback.
-
Thanks for your thoughts! I'll keep this issue open for some days before taking a final decision. Anyone feel free to weigh in. To sum up:
|
Beta Was this translation helpful? Give feedback.
-
Replacing indexedDB.cmp() with a spec compliant plain javascript implementation of indexedDB.cmp() executes between 5 and 8 times faster depending on browser. This fact could speak for solving this issue by using the plain JS function instead - but it would increase the bundle size of dexie.min.js. Chrome:
Firefox:
Safari:
Some conclusions:
So this boils down to whether it would be worth the increase of the final bundle size. |
Beta Was this translation helpful? Give feedback.
-
I could optimize the code further and make it faster for all type comparisions while also reducing code size a bit. Added unit tests for the new cmp function. PR is #1412. Implemetation of cmp: cmp.ts Now after some new measures when comparing string, we have an implementation that is about 30 times faster than the native and with reduced code size: Chrome:
Firefox:
Safari:
Bundle sizes
|
Beta Was this translation helpful? Give feedback.
-
Just discovered something is still odd with fake-indexeddb and the latest Dexie release candidate.
It seems to be able to add data to the database and retrieve it just fine, but actually there is an error on
put
andadd
calls.Best described with a repro:
I'm guessing that Dexie is trying to access the global indexedDB at some point, rather than the one passed into the options on the constructor. Here's the trace:
Beta Was this translation helpful? Give feedback.
All reactions