Skip to content

Commit 678cfd2

Browse files
authored
Merge pull request #1750 from MetaMask/failIfError
Fail if error
2 parents 4793601 + 092a9c9 commit 678cfd2

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

app/scripts/controllers/transactions.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ module.exports = class TransactionController extends EventEmitter {
2323
this.query = opts.ethQuery
2424
this.txProviderUtils = new TxProviderUtil(this.query)
2525
this.blockTracker.on('rawBlock', this.checkForTxInBlock.bind(this))
26-
this.blockTracker.on('latest', this.resubmitPendingTxs.bind(this))
26+
// this is a little messy but until ethstore has been either
27+
// removed or redone this is to guard against the race condition
28+
// where ethStore hasent been populated by the results yet
29+
this.blockTracker.once('latest', () => this.blockTracker.on('latest', this.resubmitPendingTxs.bind(this)))
2730
this.blockTracker.on('sync', this.queryPendingTxs.bind(this))
2831
this.signEthTx = opts.signTransaction
2932
this.nonceLock = Semaphore(1)
@@ -414,10 +417,24 @@ module.exports = class TransactionController extends EventEmitter {
414417
// only try resubmitting if their are transactions to resubmit
415418
if (!pending.length) return
416419
const resubmit = denodeify(this._resubmitTx.bind(this))
417-
Promise.all(pending.map(txMeta => resubmit(txMeta)))
420+
pending.forEach((txMeta) => resubmit(txMeta)
418421
.catch((reason) => {
419-
log.info('Problem resubmitting tx', reason)
420-
})
422+
/*
423+
Dont marked as failed if the error is a "known" transaction warning
424+
"there is already a transaction with the same sender-nonce
425+
but higher/same gas price"
426+
*/
427+
const errorMessage = reason.message.toLowerCase()
428+
const isKnownTx = (
429+
// geth
430+
errorMessage === 'replacement transaction underpriced'
431+
|| errorMessage.startsWith('known transaction')
432+
// parity
433+
|| errorMessage === 'gas price too low to replace'
434+
)
435+
// ignore resubmit warnings, return early
436+
if (!isKnownTx) this.setTxStatusFailed(txMeta.id, reason.message)
437+
}))
421438
}
422439

423440
_resubmitTx (txMeta, cb) {

0 commit comments

Comments
 (0)