in src/TransactionLockHelper.ts [99:119]
transactionComplete(token: TransactionToken) {
const pendingTransIndex = findIndex(this._pendingTransactions, trans => trans.token === token);
if (pendingTransIndex !== -1) {
const pendingTrans = this._pendingTransactions[pendingTransIndex];
if (pendingTrans.completionDefer) {
pendingTrans.hadSuccess = true;
const toResolve = pendingTrans.completionDefer;
this._pendingTransactions.splice(pendingTransIndex, 1);
pendingTrans.completionDefer = undefined;
toResolve.resolve(void 0);
} else {
throw new Error('Completing a transaction that has already been completed. Stores: ' + token.storeNames.join(',') +
', HadSuccess: ' + pendingTrans.hadSuccess);
}
} else {
throw new Error('Completing a transaction that is no longer tracked. Stores: ' + token.storeNames.join(','));
}
this._cleanTransaction(token);
}