IDBRequest: error property

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

* Some parts of this feature may have varying levels of support.

Note: This feature is available in Web Workers.

The error read-only property of the IDBRequest interface returns the error in the event of an unsuccessful request.

Value

A DOMException or null if there is no error. The exception object will have one of the following names, depending on what caused the error.

These errors are asynchronous, meaning that they can't be handled via try...catch. However, if an IDBRequest has an error event handler assigned, you can still inspect such errors by querying the request's error property via the event object, for example event.target.error.name or event.target.error.message.

AbortError

If you abort the transaction, then all requests still in progress receive this error.

ConstraintError

Received if you insert data that doesn't conform to a constraint when populating stores. For example, you will get this error if you try to add a new key that already exists in the store.

NotReadableError

Received for unrecoverable read failure errors. Specifically, this error signals that the record is present in the database, but the value could not be retrieved. See Transient and unrecoverable read errors below for more details.

QuotaExceededError

Received if the application runs out of disk quota. In some cases, browsers prompt the user for more space, and the error is received if they decline the request. In other cases, the browser uses heuristics to determine whether more space can be assigned.

UnknownError

Received for transient read failure errors, including general disk IO errors. See Transient and unrecoverable read errors below for more details.

VersionError

Received if you try to open a database with a version lower than the one it already has.

Transient and unrecoverable read errors

Read errors occur when an IndexedDB stores values and then subsequently fails to read those values even though the associated records are still in the database.

Read errors can be one of two types — transient or unrecoverable:

Transient read errors are signalled by an UnknownError type, and are usually caused by low memory. This shouldn't be a problem for small databases. To avoid low memory situations in large databases, try to split up database access to only load the records you need at any one time, for example using specific key ranges relating to a user's search query or a pagination mechanism. If a low memory error is hit, the user may be asked to close other applications to free up space at the OS-level.

Unrecoverable read errors are signalled by a NotReadableError type, and are caused by source files being deleted.

For example, some browsers store large values (for example, audio file blobs for an offline podcast app) as separate files that are accessed via a reference stored in the database. It has been observed that these separate files can end up being deleted because they show up as opaque files to users when they are using disk space recovery programs, resulting in unrecoverable read errors when the IndexedDB is next accessed.

Possible corrective actions for unrecoverable read errors might include notifying the user, deleting the entry from the database, then attempting to re-fetch the data from the server.

Exceptions

InvalidStateError DOMException

Thrown when attempting to access the property if the request is not completed, and therefore the error is not available.

Examples

The following example requests a given record title, onsuccess gets the associated record from the IDBObjectStore (made available as objectStoreTitleRequest.result), updates one property of the record, and then puts the updated record back into the object store. Also included at the bottom is an onerror function that reports what the error was if the request fails. For a full working example, see our To-do Notifications app (View the example live).

js
const title = "Walk dog";

// Open up a transaction as usual
const objectStore = db
  .transaction(["toDoList"], "readwrite")
  .objectStore("toDoList");

// Get the to-do list with the specified title
const objectStoreTitleRequest = objectStore.get(title);

objectStoreTitleRequest.onsuccess = () => {
  // Grab the data object returned as the result
  const data = objectStoreTitleRequest.result;

  // Update the notified value in the object to "yes"
  data.notified = "yes";

  // Create another request that inserts the item
  // back into the database
  const updateTitleRequest = objectStore.put(data);

  // When this new request succeeds, run the displayData()
  // function again to update the display
  updateTitleRequest.onsuccess = () => {
    displayData();
  };
};

objectStoreTitleRequest.onerror = () => {
  // If an error occurs with the request, log what it is
  console.log(
    `There has been an error with retrieving your data:
    ${objectStoreTitleRequest.error.name}: ${objectStoreTitleRequest.error.message}`,
  );
};

Specifications

Specification
Indexed Database API 3.0
# ref-for-dom-idbrequest-error①

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
error
Chrome – Full support
Chrome 23 (Release date: 2012-11-06)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 10 (Release date: 2012-01-31)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – Full support
Chrome Android 25 (Release date: 2013-02-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 22 (Release date: 2013-06-25)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
DOMException value instead of DOMError
Chrome – Full support
Chrome 48 (Release date: 2016-01-20)
footnote Full support
Edge – Full support
Edge 18 (Release date: 2018-10-02)
footnote Full support
Firefox – Full support
Firefox 58 (Release date: 2018-01-23)
footnote Full support
Opera – Full support
Opera 35 (Release date: 2016-02-02)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 48 (Release date: 2016-01-26)
footnote Full support
Firefox for Android – Full support
Firefox for Android 58 (Release date: 2018-01-22)
footnote Full support
Opera Android – Full support
Opera Android 35 (Release date: 2016-02-04)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 5 (Release date: 2016-12-15)
footnote Full support
WebView Android – Full support
WebView Android 48 (Release date: 2016-01-26)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support
Transient and unrecoverable read errors
Chrome – Partial support
Chrome 130 – 131 (Release date: 2024-10-15)
footnote Partial support
footnote Returns a NotFoundError exception for unrecoverable read errors, and a DataError for transient read errors.
Chrome – Full support
Chrome 132 (Release date: 2025-01-14)
footnote
footnote Returns a NotReadableError exception for unrecoverable read errors, and an UnknownError for transient read errors.
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 14 (Release date: 2012-07-17)
footnote Full support
Opera – Partial support
Opera 115 – 116 (Release date: 2024-11-27)
footnote Partial support
footnote Returns a NotFoundError exception for unrecoverable read errors, and a DataError for transient read errors.
Opera – Full support
Opera 117 (Release date: 2025-02-13)
footnote
footnote Returns a NotReadableError exception for unrecoverable read errors, and an UnknownError for transient read errors.
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – Partial support
Chrome Android 130 – 131 (Release date: 2024-10-15)
footnote Partial support
footnote Returns a NotFoundError exception for unrecoverable read errors, and a DataError for transient read errors.
Chrome Android – Full support
Chrome Android 132 (Release date: 2025-01-14)
footnote
footnote Returns a NotReadableError exception for unrecoverable read errors, and an UnknownError for transient read errors.
Firefox for Android – Full support
Firefox for Android 22 (Release date: 2013-06-25)
footnote Full support
Opera Android – Partial support
Opera Android 86 – 86 (Release date: 2024-12-02)
footnote Partial support
footnote Returns a NotFoundError exception for unrecoverable read errors, and a DataError for transient read errors.
Opera Android – Full support
Opera Android 87 (Release date: 2025-01-22)
footnote
footnote Returns a NotReadableError exception for unrecoverable read errors, and an UnknownError for transient read errors.
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – Partial support
Samsung Internet 28 – 28 (Release date: 2025-04-02)
footnote Partial support
footnote Returns a NotFoundError exception for unrecoverable read errors, and a DataError for transient read errors.
Samsung Internet – Full support
Samsung Internet 29 (Release date: 2025-10-25)
footnote
footnote Returns a NotReadableError exception for unrecoverable read errors, and an UnknownError for transient read errors.
WebView Android – Partial support
WebView Android 130 – 131 (Release date: 2024-10-15)
footnote Partial support
footnote Returns a NotFoundError exception for unrecoverable read errors, and a DataError for transient read errors.
WebView Android – Full support
WebView Android 132 (Release date: 2025-01-14)
footnote
footnote Returns a NotReadableError exception for unrecoverable read errors, and an UnknownError for transient read errors.
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.
Has more compatibility info.

See also