ngx-indexed-db icon indicating copy to clipboard operation
ngx-indexed-db copied to clipboard

Unable to delete database because it's blocked

Open EmadR opened this issue 1 year ago • 14 comments

when i call this.dbService.deleteDatabase().subscribe((deleted) => { console.log('Database deleted successfully: ', deleted); });

log in console: ERROR Error: Unable to delete database because it's blocked at deleteDBRequest.onblocked [as __zone_symbol__ON_PROPERTYblocked] (ngx-indexed-db.mjs:531:27)

EmadR avatar Jun 11 '23 06:06 EmadR

Hi @EmadR, most likely there is an open connection to that database somewhere.

aparzi avatar Jun 11 '23 13:06 aparzi

hi @aparzi how to close all connections?

EmadR avatar Jun 12 '23 03:06 EmadR

You generally never need to close a connection. Except if You may wish to explicitly close a connection if you anticipate upgrading your database schema. Here's the scenario:

  1. A user opens your site in one tab, and leaves it open.

  2. You push an update to your site, which includes code to upgrade the database schema, increasing the version number.

  3. The same user opens a second tab to your site and it attempts to connect to the database.

What situation do you have?

aparzi avatar Jun 12 '23 07:06 aparzi

I have a panel, when the user logs in, I get information from server and save it in the form of a table in indexeddb. Now, when the same user wants to exit the panel, I delete the database and it gives the error I said

EmadR avatar Jun 12 '23 15:06 EmadR

how do you save the information in the database?

aparzi avatar Jun 12 '23 15:06 aparzi

const dbConfig: DBConfig = { name: 'MyDb', version: 1, objectStoresMeta: [{ store: 'employee', storeConfig: { keyPath: 'id', autoIncrement: true }, storeSchema: [] }] };

this.dbService .add('employee', response.data) .subscribe((key) => { console.log('key: ', key); });

EmadR avatar Jun 13 '23 04:06 EmadR

Okay, I will investigate the issue.

aparzi avatar Jun 13 '23 06:06 aparzi

Hi @EmadR, why your storeSchema is empty array? can you add your store schema?

Example: storeSchema: [ { name: 'name', keypath: 'name', options: { unique: false } }, { name: 'email', keypath: 'email', options: { unique: false } }, ]

aparzi avatar Jun 13 '23 10:06 aparzi

HI @EmadR, any news?

aparzi avatar Jun 14 '23 10:06 aparzi

Must it be set? Because for the update, the response I get may not match the configuration and the keys may be different

EmadR avatar Jun 14 '23 11:06 EmadR

What do you mean update?

aparzi avatar Jun 14 '23 12:06 aparzi

I may receive new data from the server and have to update my table. This is what I mean by update.

EmadR avatar Jun 17 '23 03:06 EmadR

Hi @EmadR, did you solve the problem?

aparzi avatar Aug 04 '23 08:08 aparzi

hi @aparzi , no

EmadR avatar Aug 05 '23 04:08 EmadR