jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.4k stars 360 forks source link

Safari IndexedDb duplicate db #72

Closed honia19 closed 3 years ago

honia19 commented 5 years ago

I created issue on stackoverflow link with screenshort This bug reproduce only in Safari https://stackoverflow.com/questions/53560736/indexeddb-duplicate-only-in-safari Code:

    Idb.initDb()
        .then(isUpdate => {
                console.log(isUpdate);
            }
        ).catch((error) => {
        console.log(error);
    });

    static initDb = async () => {
        const db = await idb.open(dbState.name, dbState.version, (upgradeDB) => {
            dbState.stores.forEach((store) => {
                if (!upgradeDB.objectStoreNames.contains(store)) {
                    upgradeDB.createObjectStore(store);
                    console.log('The store -', store, ' was added to db');
                }
            })
        });
    };
vishnumanjunath commented 5 years ago

Same issue, when you navigate to different website and come back it creates duplicate DB.

ywen commented 5 years ago

The issue doesn't seem to be specific to this library. I use Dexie and the same problem appears

mlrv commented 4 years ago

Is there any update on this? I'm seeing the same issue, just on Safari

jakearchibald commented 4 years ago

I suspect this is a Safari bug rather than anything to do with this library, but if someone can come up with a minimal reproduction and steps, I can take a look.

mlrv commented 4 years ago

I suspect this is a Safari bug rather than anything to do with this library, but if someone can come up with a minimal reproduction and steps, I can take a look.

Hey @jakearchibald, thanks for the swift response. I also believe this is a Safari bug and has nothing to do with idb itself. It might also be just a UI bug and the browser isn't actually creating multiple databases (it should also be impossible to create two dbs with the same name I assume?), I'll see if I can find out more.

jakearchibald commented 4 years ago

Yeah, databases are unique per name per origin.

If there isn't any data loss associated with this, then I suspect it's just a UI bug. I guess you could look into the profile and if the information is actually duplicated.

sachinrekhi commented 4 years ago

I'm seeing the exact same duplicate IndexedDB issue with Safari 13.1.1 on Mac 10.15.5. My guess though is that it's an issue with Safari's IDB browser, because when I make a change to a key, that change is reflected in both versions of the databases shown in the browser, suggesting they are actually the same underlying data, not in-fact two separate databases.

jakearchibald commented 3 years ago

Please reopen this with a minimal reproduction, if you think it's an issue with the library rather than an issue with Safari.