8000 Better bad transaction error and auto reset database from unrecoverable state by Kuuuube · Pull Request #2031 · yomidevs/yomitan · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Better bad transaction error and auto reset database from unrecoverable state #2031

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

Merged
merged 2 commits into from
Jun 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ext/js/data/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import {toError} from '../core/to-error.js';

/**
* @template {string} TObjectStoreName
*/
Expand Down Expand Up @@ -47,6 +49,12 @@ export class Database {
this._upgrade(db, transaction, oldVersion, structure);
}
});
if (this._db.objectStoreNames.length === 0) {
this.close();
await Database.deleteDatabase(databaseName);
this._isOpening = false;
await this.open(databaseName, version, structure);
}
} finally {
this._isOpening = false;
}
Expand Down Expand Up @@ -91,7 +99,11 @@ export class Database {
if (this._db === null) {
throw new Error(this._isOpening ? 'Database not ready' : 'Database not open');
}
return this._db.transaction(storeNames, mode);
try {
return this._db.transaction(storeNames, mode);
} catch (e) {
throw new Error(toError(e).message + '\nDatabase transaction error, you may need to Delete All dictionaries to reset the database or manually delete the Indexed DB database.');
}
}

/**
Expand Down
0