Add idb global database failure error as reason to transaction errors #8414
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When you exceed storage quota with pouchdb and idb (on chrome) this happens in order:
DOMExceptionwithname: "QuotaExceededError"is logged to console https://github.com/pouchdb/pouchdb/blob/a33bc407407f97b9f2382db364f9e49a0fa03b62/packages/node_modules/pouchdb-adapter-idb/src/index.js#L696CustomPouchErrorwithname: "indexed_db_went_bad", reason: "QuotaExceededError"DOMExceptionwithname: "InvalidStateError", message: "Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing.". Thrown on this line: https://github.com/pouchdb/pouchdb/blob/a33bc407407f97b9f2382db364f9e49a0fa03b62/packages/node_modules/pouchdb-adapter-idb/src/utils.js#L220Exception from step 1 are discarded by idb adapter (user code can't access them). This is a problem but this PR does not address it fully.
Exception from step 3 propagate to user code and have a meaningful reason string that can be used by user code to acknowledge the quota error. This is ok but IMO could be improved by using the original error object instead of just a string as a reason. This PR does not address it.
Exceptions from step 4 propagate to user code but do not have any data that can be used to link them to the original quota error from step 1. This is bad. This PR fixes this by attaching the exception from step 1 to exceptions from step 4 as a
reasonproperty.You can find many stale pouchdb issues with
InvalidStateErrors of unknown origin. This could help users understand, debug and possibly programmatically recover from them or show meaningful error messages to user.