5.4. Committing a transaction
To commit a transaction with the transaction to commit, run these steps:
Set transaction’s state to committing.
Run the following steps in parallel:
Wait until every item in transaction’s request list is processed.
If transaction’s state is no longer committing, then terminate these steps.
Attempt to write any outstanding changes made by transaction to the database, considering transaction’s durability hint.
If an error occurs while writing the changes to the database, then run abort a transaction with transaction and an appropriate type for the error, for example “
[QuotaExceededError](https://heycam.github.io/webidl/#quotaexceedederror)
“ or “[UnknownError](https://heycam.github.io/webidl/#unknownerror)
“[DOMException](https://heycam.github.io/webidl/#idl-DOMException)
, and terminate these steps.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
complete
at transaction.Even if an exception is thrown from one of the event handlers of this event, the transaction is still committed since writing the database changes happens before the event takes places. Only after the transaction has been successfully written is the
complete
event fired.If transaction is an upgrade transaction, then let request be the request associated with transaction and set request’s transaction to null.