dexie / Dexie.js

A Minimalistic Wrapper for IndexedDB
https://dexie.org
Apache License 2.0
11.07k stars 631 forks source link

Incomaptibility between Dexie.js v4.0.7 and @opentelemetry/context-zone 1.18.1 even with forcing last version of zone.js version 0.14.6 #2005

Open AMontagu opened 1 month ago

AMontagu commented 1 month ago

Hello,

We are trying to use the last version of RxDB with the Dexie connector. The RxDB issue is created even if it's a incomaptibility between others package (https://github.com/pubkey/rxdb/issues/6008)

Basically Zone.js used in @opentelemetry/context-zone override the default Promise object. But Dexie warn that if it happen the async transactions will not work. We was able to assert with debugger that this line is called https://github.com/dexie/Dexie.js/blob/d8d85270130db72aa93e242732539d3e85480081/src/helpers/promise.js#L617

So this line: https://github.com/dexie/Dexie.js/blob/d8d85270130db72aa93e242732539d3e85480081/src/classes/dexie/transaction-helpers.ts#L77C7-L77C30 is doing nothing and we have the error of PrematureCommit explained in the RxDB issue. It is of course the expected behavior as zone.js is overriding the Promise object but as it is a really common tracing library I am wondering if it will be possible to support the zone.js promise object too ?

dfahlander commented 1 month ago

If I get a repro I could try to debug it. Generally, Zone.js have been working with Dexie. At least when transpiling down to ES2016 or earlier which is needed anyway in order for Zone.js to be able to wrap around await calls as it cannot intercept native await.

Mike-FR commented 1 month ago

Hello, i'm working whit @AMontagu . Following this link you will get a minimal repo with the error.
https://github.com/Mike-FR/rxdb-dexie-zone-test/

npm install
npm run dev

image

In the main.js, if you comment the import from "@grafana/faro-web-tracing", the error disappear.

Thanks for the help.

Mike-FR commented 2 weeks ago

any updates on the issue? @dfahlander

dfahlander commented 2 weeks ago

I've spent some time with the repro but this will need deep diving to find out the culprit. There are other tasks pressuring me right now that I have to deal with before spending more time on this issue. I'm sorry but the reality for me is that I work for free half time and for paid the other half. If this is urgent, please sponsor Dexie.js. Don't mean that I require sponsoring to fix it - I also want dexie to be the best in class and work with all other libraries, just that I need to prioritize this project now. I hope everyone understands.

AMontagu commented 1 week ago

Yes we totally understand. We will see for sponsoring or debugging it ourself and make a PR.

As is is just blocking an update to the latest version of RxDB and Dexie is not our top priority either.