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

Chrome switching between asyncStorage and webSQLStorage on page reload #188

Closed
MatthewAlner opened this issue Jun 30, 2020 · 9 comments
Closed

Comments

@MatthewAlner
Copy link

version: "@ionic/storage": "^2.2.0"
chrome version: 83.0.4103.116 (Official Build) (64-bit)

On first page load it uses asyncStorage then on a hard refresh or if I make a code change and it reloads, it swaps to using webSQLStorage. This doesn't happen in Safari or Firefox as far as I can tell.

I have worked around the issue by specifying my drivers an omitting websql

    IonicStorageModule.forRoot({
      driverOrder: ['indexeddb', 'sqlite'],
    }),

before I didn't pass anything, IonicStorageModule.forRoot()

Here is a video of the issue

https://youtu.be/CZN_cTlPd6U

Cheers,

Matt

@lincolnthree
Copy link

Also having this issue. It's super strange.

@lincolnthree
Copy link

Seems to be related to indexeddb not being ready:

When indexeddb is the only driver selected:

driverOrder: ['indexeddb']
rror: No available storage method found.
Error: No available storage method found.
    at :8100/vendor.js:56260:25 [angular]
    at Object.onInvoke (vendor.js:113715) [angular]
    at :8100/polyfills.js:7361:40 [angular]
    at Object.onInvokeTask (vendor.js:113703) [angular]
    at drainMicroTaskQueue (zone.js:583) [<root>]
    at resolvePromise (zone.js:1215) [angular]
    at resolvePromise (zone.js:1165) [angular]
    at :8100/polyfills.js:7364:21 [angular]
    at Object.onInvokeTask (vendor.js:113703) [angular]
    at drainMicroTaskQueue (zone.js:583) [<root>]

@lincolnthree
Copy link

lincolnthree commented Oct 16, 2020

I believe this is the cause. LocalForage does not seem to detect Chrome's indexedDb reliably:

localForage/localForage#999

Worse yet, @ionic/storage (or NPM) forces an dependency version of localForage that needs to be overridden to patch this.

@mlynch
Copy link
Contributor

mlynch commented Mar 9, 2021

v3 which will be out in a few weeks uses the latest of localForage so going to close this

@mlynch mlynch closed this as completed Mar 9, 2021
@lincolnthree
Copy link

lincolnthree commented Mar 10, 2021

@mlynch I do not believe my PR with the fix was merged into localForage. This issue should probably not be closed.

To be honest, the localForage project seems mostly dead/unmaintained now. You might consider forking it or switching to something else.

@mlynch
Copy link
Contributor

mlynch commented Mar 10, 2021

Strange, I'm looking at your PR and it's essentially doing the same thing as the code that is already there. the idb isn't a chrome global, it's coming from the import in utils/idb.js which is pulling window.indexedDB. I would be shocked if window.indexedDB isn't available immediately as the script runs 🤔

Will keep an eye on it though, thanks for the info.

@lincolnthree
Copy link

@mlynch I'd be lying if I said I fully understand how browsers are providing IDB. And, honestly, the loss of WEBSQL is a real disappointment. The number of inconsistently reproducible IDB bugs (particularly with Safari) is stunning.

@sebaferreras
Copy link

@lincolnthree I think I'm experiencing the same issue... were you able to find a workaround or at least more information about why it happens? Thanks :)

@lincolnthree
Copy link

lincolnthree commented Jun 3, 2023

My workaround was to fork localForage, use the PR I submitted, and force everything to use my version -- since the project seems not to be maintained any longer. It seems there may be a better solution, but I haven't tried it, since what I have works and I don't want to mess with it and risk breaking things :)

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

4 participants