1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

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

This commit is contained in:
kumavis 2018-06-12 10:55:54 -07:00
parent f08442e266
commit 8f93e34175

View File

@ -49,6 +49,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)
@ -72,6 +73,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 _getCurrentBlock () { async _getCurrentBlock () {