5.5. Aborting a transaction
To abort a transaction with the transaction to abort, and error, run these steps:
All the changes made to the database by the transaction are reverted. For upgrade transactions this includes changes to the set of object stores and indexes, as well as the change to the version. Any object stores and indexes which were created during the transaction are now considered deleted for the purposes of other algorithms.
If transaction is an upgrade transaction, run the steps to abort an upgrade transaction with transaction.
This reverts changes to all connection, object store handle, and index handle instances associated with transaction.
If error is not null, set transaction’s error to error.
For each request of transaction’s request list, abort the steps to asynchronously execute a request for request, set request’s processed flag to true, and queue a task to run these steps:
Set request’s done flag to true.
Set request’s result to undefined.
Set request’s error to a newly created “
[AbortError](https://heycam.github.io/webidl/#aborterror)
“[DOMException](https://heycam.github.io/webidl/#idl-DOMException)
.Fire an event named
error
at request with its[bubbles](https://dom.spec.whatwg.org/#dom-event-bubbles)
and[cancelable](https://dom.spec.whatwg.org/#dom-event-cancelable)
attributes initialized to true.
This does not always result in any [`error`](#eventdef-request-error) events being fired. For example if a transaction is aborted due to an error while [committing](#transaction-committing) the transaction, or if it was the last remaining request that failed.
Queue a task to run these steps:
If transaction is an upgrade transaction, then set transaction’s connection‘s associated database‘s upgrade transaction to null.
Fire an event named
abort
at transaction with its[bubbles](https://dom.spec.whatwg.org/#dom-event-bubbles)
attribute initialized to true.If transaction is an upgrade transaction, then:
Let request be the open request associated with transaction.
Set request’s transaction to null.
Set request’s result to undefined.
Set request’s processed flag to false.
Set request’s done flag to false.