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

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

Closed
alex-hladun opened this issue Jan 30, 2024 · 12 comments

Comments

@alex-hladun
Copy link
Contributor

alex-hladun commented Jan 30, 2024

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'

@pubkey
Copy link
Owner

pubkey commented Jan 30, 2024

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.

@pubkey
Copy link
Owner

pubkey commented Jan 30, 2024

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.

@alex-hladun
Copy link
Contributor Author

@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?

@pubkey
Copy link
Owner

pubkey commented Jan 31, 2024

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.

@alex-hladun
Copy link
Contributor Author

alex-hladun commented Jan 31, 2024

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

@pubkey
Copy link
Owner

pubkey commented Jan 31, 2024

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

@pubkey
Copy link
Owner

pubkey commented Jan 31, 2024

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.

@alex-hladun
Copy link
Contributor Author

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

@pubkey
Copy link
Owner

pubkey commented Jan 31, 2024

@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

@pubkey
Copy link
Owner

pubkey commented Jan 31, 2024

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

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

@pubkey pubkey closed this as completed in b368ad9 Jan 31, 2024
@pubkey pubkey reopened this Jan 31, 2024
@pubkey
Copy link
Owner

pubkey commented Jan 31, 2024

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.

@alex-hladun
Copy link
Contributor Author

Great, thanks for taking a look!

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