nonce-tracker - wrap nonce calculations in try-catch and release lock on error

feature/default_network_editable
kumavis 7 years ago
parent 030fea7136
commit c86f935889
  1. 6
      app/scripts/controllers/transactions/nonce-tracker.js

@ -50,6 +50,7 @@ class NonceTracker {
await this._globalMutexFree() await this._globalMutexFree()
// await lock free, then take lock // await lock free, then take lock
const releaseLock = await this._takeMutex(address) const releaseLock = await this._takeMutex(address)
try {
// evaluate multiple nextNonce strategies // evaluate multiple nextNonce strategies
const nonceDetails = {} const nonceDetails = {}
const networkNonceResult = await this._getNetworkNextNonce(address) const networkNonceResult = await this._getNetworkNextNonce(address)
@ -73,6 +74,11 @@ class NonceTracker {
// return nonce and release cb // return nonce and release cb
return { nextNonce, nonceDetails, releaseLock } return { nextNonce, nonceDetails, releaseLock }
} catch (err) {
// release lock if we encounter an error
releaseLock()
throw err
}
} }
async _globalMutexFree () { async _globalMutexFree () {

Loading…
Cancel
Save