cyrilletuzi / angular-async-local-storage

Efficient client-side storage for Angular: simple API + performance + Observables + validation
MIT License
676 stars 68 forks source link

Issues with object store after clearing browsing data #1007

Closed gimmeshelter closed 6 months ago

gimmeshelter commented 6 months ago

Checks before posting an issue

Configuration

Angular CLI: 17.3.3 Node: 21.1.0 (Unsupported) Package Manager: yarn 1.22.22 OS: darwin arm64

Angular: 17.3.3 ... animations, cli, common, compiler, compiler-cli, core, forms ... language-service, localize, platform-browser ... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.1703.3 @angular-devkit/build-angular 17.3.3 @angular-devkit/core 17.3.3 @angular-devkit/schematics 17.3.3 @schematics/angular 17.3.3 ng-packagr 17.1.2 rxjs 7.8.1 typescript 5.3.3 zone.js 0.14.3



# Description of the issue

Recently during testing, I cleared my browsing data in Chrome (123.0.6312.124) using their Clear Browsing Data utility.  I cleared data for the last hour.  In doing so, Chrome removed the 'localStorage' object store, but not the 'ngStorage' database from IndexedDB.  When I tried to load my app, I started receiving errors like the following: "Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found."  I have tested the scenario repeatedly and always get the same result and the 'localStorage' object store is never recreated.

# How to reproduce the issue

1. Allow the Angular app to create some data in IndexedDB
2. Verify that the `ngDatabase` > `localStorage` items are present in IndexedDB
3. In Chrome, use the "Clear Browsing Data" utility to clear browsing data for the last hour
4. Verify that the `ngDatabase` item exists in IndexedDB, but the `localStorage` object store doesn't exist under `ngDatabase`
5. Refresh your Angular app that uses local-storage and you should see the error noted above and the `localStorage` object store is not recreated under `ngDatabase`
cyrilletuzi commented 6 months ago

Hello @gimmeshelter, thank you for the helpful report which should allow me to reproduce. I will look into it soon and get back to you.

cyrilletuzi commented 6 months ago

@gimmeshelter I have a few questions:

Asking these questions because I cannot reproduce on my side: when I clear browsing data in latest Chrome (Version 124.0.6367.62 (Build officiel) (arm64)) on MacOS (so same configuration as you), both the localStorage object store and the ngDatabase database are deleted by Chrome.

gimmeshelter commented 6 months ago

@cyrilletuzi I can no longer reproduce this despite reproducing 20x throughout the day yesterday. I am willing to call it a fluke and close.

To answer your questions:

cyrilletuzi commented 6 months ago

I can no longer reproduce this despite reproducing 20x throughout the day yesterday. I am willing to call it a fluke and close.

Has your Chrome version changed since? There was the v124 update yesterday/today.

gimmeshelter commented 6 months ago

I can no longer reproduce this despite reproducing 20x throughout the day yesterday. I am willing to call it a fluke and close.

Has your Chrome version changed since? There was the v124 update yesterday/today.

No. During testing today, I was still using 123.0.6312.124. I am in a corporate environment and our updates are centrally controlled, so we're not always on the latest.

cyrilletuzi commented 6 months ago

Noted.

I will close the issue for now, because in any cases it would be a browser bug. In indexedDb, object stores can only be created during the database creation or update. So having the object store deleted by the browser but not the database would cause an impossible situation to solve for libraries and applications.

gimmeshelter commented 6 months ago

Noted.

I will close the issue for now, because in any cases it would be a browser bug. In indexedDb, object stores can only be created during the database creation or update. So having the object store deleted by the browser but not the database would cause an impossible situation to solve for libraries and applications.

Understood. Thank you for looking into it and I apologize for the false alarm.