Closed kwlayman closed 3 years ago
This is the trace from the error I'm getting in webworker when switching database connections between two apps. Switching between them works fine but if one makes a call to a table that doesn't exist, then that throws an error, and then any subsequent calls to existing tables fail with this and looking at the code in worker I can't figure out the issue so I'm trying to get it to stop using worker in the hope I can debug easier, but no luck with that.
jsstore.worker.min.js:6 Uncaught (in promise) TypeError: Cannot read property 'version' of undefined at jsstore.worker.min.js:6 (anonymous) @ jsstore.worker.min.js:6 Promise.then (async) e.isDbExist @ jsstore.worker.min.js:6 e.executeLogic @ jsstore.worker.min.js:6 e.checkConnectionAndExecuteLogic @ jsstore.worker.min.js:6 e.sendRequestToWorker @ jsstore.min.js:6 e.executeQry @ jsstore.min.js:6 e.processFinishedQuery @ jsstore.min.js:6 e.returnResult @ jsstore.worker.min.js:6 r @ jsstore.worker.min.js:6 Promise.then (async) e.openDb @ jsstore.worker.min.js:6 e.executeLogic @ jsstore.worker.min.js:6 e.checkConnectionAndExecuteLogic @ jsstore.worker.min.js:6 e.sendRequestToWorker @ jsstore.min.js:6 e.executeQry @ jsstore.min.js:6 e.prcoessExecutionOfQry @ jsstore.min.js:6 e.openDb @ jsstore.min.js:6 (anonymous) @ jsstore.min.js:6 e.pushApi @ jsstore.min.js:6 t.isDbExist @ jsstore.min.js:6 initJsStoreDb @ dbMan.js:294 SetActiveApp @ modelMan.js:2701 appSwitcher @ modelMan.js:390 onclick @ VM35485 index.html:1
Also on the above error I get nothing back from JSStore that I can use in any callbacks, so my code gets stuck waiting on return from query that never comes nor throws error I can detect except in chrome debugger.
Actually the error is occurring on the isDbExist call after opening a database, switching to another with no problem, and then switching OR trying to open the same one.
After much mucking around and trying different things, including creating and storing separate connections, it appears that the problem is that I designate databases by number, ie "1". And somehow it appears to me that in the worker code following a call to openDb, which I can find no docs for but in examples appears to only take one param, it keeps throwing an error about database version 1 being less than existing 3.
After changing my database naming scheme to 'db' + x, the problem seems to have gone away, but I will update here after some more testing.
it keeps throwing an error about database version 1 being less than existing 3.
it clearly says that your current database version is 3 but you are passing 1. If you will pass 4 then your db scheme will be updated and everything will work normal.
here is doc - https://jsstore.net/tutorial/change-table-design/
No, as I described I'm passing in a database name to isDbExist and it is somehow interpreting that as a version. I can't even find in the docs where isDbExist takes a version parameter.
Regardless as described I fixed it by no longer passing a number like '1', now I pass 'db1'.
The original issue here is that worker gets called even when I don't want to use it.
The issue with database version has been resolved by switching to the new version of Jsstore and changing database naming scheme that no longer starts with numeric string character.
On the original issue I cannot get jsstore to work w/o the worker.min.js file present even if I don't reference it in new JsStore.Connection(worker file), so if this is by design I missed it and you can close this.
yes, thats by design when you don't use it as worker, you will have to include the script.
Cannot use JSStore without webworker
I keep getting version errors that are impossible to debug in the webworker code, and when I try to use JSStore without it it still gets called.
I saw the closed issues where you gave examples of how to start JSStore w/o worker, but .instance is now deprecated and even though I pass no worker file to .connection it apparently is still trying to make calls to worker.