pubkey / rxdb

A fast, local first, reactive Database for JavaScript Applications https://rxdb.info/

Home Page:https://rxdb.info/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with 'could not requestRemote' during migration from v14 -> v15 (indexedDb RxStorage)

alex-hladun opened this issue · comments

Hello, was recently working on upgrading our prod db instance from v14 to v15. Running into an error which occurs during the migration process.

rx-storage-remote.ts:220 Uncaught (in promise) Error: could not requestRemote: { "methodName": "cleanup", "params": [ 0 ], "error": { "name": "NotFoundError", "message": "Failed to execute 'index' on 'IDBObjectStore': The specified index was not found.", "code": 8, "stack": "Error: Failed to execute 'index' on 'IDBObjectStore': The specified index was not found. \n at t.cleanup (http://localhost:8888/indexeddb.worker.js:1:84335) \n at async Object.next (http://localhost:8888/indexeddb.worker.js:1:90902)"

I was unable to make a unit test, due to the complex nature of the migration:

  • Had to install both Rxdb-14 and Rxdb-14-Premium to use the getRxStorageWorker and RxStorageIndexedDBStatics in order to re-create the storage for v14.
  • Since rxdb-premium imports directly from rxdb, and lots of code was re-written between 14 and 15, I copied over the rxdb 14 internals into the project itself and changed references to rxdb-14 from within the rxdb-premium-14 code.
  • I created an example reproducible Private repo and added you as a collaborator, as I cannot share Rxdb-premium internals! To test, add a hero, and then click 'Migrate to v15'. Repo is here: https://github.com/alex-hladun/rxdb-14to15migration

Note: The data still migrates succesffully after refresh. However, in our prod app, not all data migrates and we get the same error during 'cleanup'

Hi @alex-hladun
Thanks for reporting, I will look into that.

The call to .cleanup() is optional and for a quick fix you might just want to copy the migration plugin code and remove that line.

Are you using the same indexeddb.worker.js file for both versions?
Because that does not work, you need the v14 worker file for v14 remote storage and v15 worker.js for the v15 storage.

@pubkey Thanks! I'm serving the v14 worker inside the public folder, I thought v15 provided the indexeddb.worker.js link from within the rxdb-premium repo?

No you still have to copy the worker over to somewhere your webserver can serve it. So you should copy it also to the public folder.

How does getRxStorageIndexedDB() v15 know which worker file to reference? I don't see that option in the args

You have to specify the different worker url in the remote storage.

Ah I see. So in your example you not only migrate v14 to v15, but also the worker storage to the non-worker plain indexeddb storage.

@pubkey No, my intention was to stick with the worker storage. Fixed that, pushed it up, still seeing the cleanup crash.

@alex-hladun I cannot see the change in the repo, are you sure you pushed it?
Also please update to newest RxDB version 15.5.0 instead of 15.3.0

@alex-hladun I cannot see the change in the repo, are you sure you pushed it?

Ah, there is a 14-15migration branch..

Thank you for your example code. I could reproduce the problem also on newest RxDB 15.5.0.

For fixing, I wrapped ii in a try catch to fix the error. Calling .cleanup() during migration is optional so that fixes the migration. Im an not sure if .cleanup() should be called anyway because it reduces migration performance.

Great, thanks for taking a look!