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

Conversation

Kuuuube
Copy link
Member
@Kuuuube Kuuuube commented May 31, 2025

Addresses #1847 (comment)

If the database gets into a state where there are no object stores, there is also no data present and it is safe to delete the database to recover. It may not be safe to delete the database in other situations, so the user will be presented with a more descriptive error instead if it hits a transaction failure.

Transaction failures seem to be almost always caused by a missing object store and would be an unrecoverable state even if only a single one is missing but there is no evidence of such cases occurring and I currently do not like the idea of potentially bulldozing user data for recovery. In a database corruption with missing object stores it is still technically possible for the user to manually extract some amount of data even if only one object store is present.

It is not possible to repair the database on Yomitan's end after losing some or all of the object stores without pushing a version change which are meant to be for schema updates and it is probably not a good idea to throw them around arbitrarily as it could cause the database to be unopenable or impossible to update in the future if the version number is something unexpected.

https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase/createObjectStore

To intentionally create a broken database with missing object stores, throw an error right after opening the database here:

const request = indexedDB.open(name, version);

For example:

const request = indexedDB.open(name, version);
throw new Error('break the thing');

@Kuuuube Kuuuube requested a review from a team as a code owner May 31, 2025 04:22
@Kuuuube Kuuuube added the kind/enhancement The issue or PR is a new feature or request label May 31, 2025
Copy link
Collaborator
@jamesmaa jamesmaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

@Kuuuube Kuuuube added this pull request to the merge queue Jun 3, 2025
Merged via the queue into yomidevs:master with commit fe04d21 Jun 3, 2025
25 checks passed
@Kuuuube Kuuuube deleted the better-bad-transaction-error branch June 3, 2025 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement The issue or PR is a new feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0