aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2017-07-07 18:23:34 +0800
committerGitHub <noreply@github.com>2017-07-07 18:23:34 +0800
commit678cfd21755bab430d28a8f0d0fb44a81ecefade (patch)
tree21b3fe9bb287c9c0ddaa0d4ecba602922acc0bab
parent47936019d237f3603e14508ea76922fabb4ca0aa (diff)
parent092a9c9defd4d9bd2db7f969a8076c8b624d30bb (diff)
downloadtangerine-wallet-browser-678cfd21755bab430d28a8f0d0fb44a81ecefade.tar
tangerine-wallet-browser-678cfd21755bab430d28a8f0d0fb44a81ecefade.tar.gz
tangerine-wallet-browser-678cfd21755bab430d28a8f0d0fb44a81ecefade.tar.bz2
tangerine-wallet-browser-678cfd21755bab430d28a8f0d0fb44a81ecefade.tar.lz
tangerine-wallet-browser-678cfd21755bab430d28a8f0d0fb44a81ecefade.tar.xz
tangerine-wallet-browser-678cfd21755bab430d28a8f0d0fb44a81ecefade.tar.zst
tangerine-wallet-browser-678cfd21755bab430d28a8f0d0fb44a81ecefade.zip
Merge pull request #1750 from MetaMask/failIfError
Fail if error
-rw-r--r--app/scripts/controllers/transactions.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index 7946d10d1..41d70194e 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -23,7 +23,10 @@ module.exports = class TransactionController extends EventEmitter {
this.query = opts.ethQuery
this.txProviderUtils = new TxProviderUtil(this.query)
this.blockTracker.on('rawBlock', this.checkForTxInBlock.bind(this))
- this.blockTracker.on('latest', this.resubmitPendingTxs.bind(this))
+ // this is a little messy but until ethstore has been either
+ // removed or redone this is to guard against the race condition
+ // where ethStore hasent been populated by the results yet
+ this.blockTracker.once('latest', () => this.blockTracker.on('latest', this.resubmitPendingTxs.bind(this)))
this.blockTracker.on('sync', this.queryPendingTxs.bind(this))
this.signEthTx = opts.signTransaction
this.nonceLock = Semaphore(1)
@@ -414,10 +417,24 @@ module.exports = class TransactionController extends EventEmitter {
// only try resubmitting if their are transactions to resubmit
if (!pending.length) return
const resubmit = denodeify(this._resubmitTx.bind(this))
- Promise.all(pending.map(txMeta => resubmit(txMeta)))
+ pending.forEach((txMeta) => resubmit(txMeta)
.catch((reason) => {
- log.info('Problem resubmitting tx', reason)
- })
+ /*
+ Dont marked as failed if the error is a "known" transaction warning
+ "there is already a transaction with the same sender-nonce
+ but higher/same gas price"
+ */
+ const errorMessage = reason.message.toLowerCase()
+ const isKnownTx = (
+ // geth
+ errorMessage === 'replacement transaction underpriced'
+ || errorMessage.startsWith('known transaction')
+ // parity
+ || errorMessage === 'gas price too low to replace'
+ )
+ // ignore resubmit warnings, return early
+ if (!isKnownTx) this.setTxStatusFailed(txMeta.id, reason.message)
+ }))
}
_resubmitTx (txMeta, cb) {