mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Do not mark a retry tx failed that has been broadcast successfully
Fixes #2115 If a tx has been braodcast, the only failures we should accept are: - Never mined - On chain failure We had a section of code that would mark a tx failed during any unknown error during a retry. Now no retry > 1 will ever mark a tx failed, since it has been broadcast, and may be mined.
This commit is contained in:
parent
c9ac8f0919
commit
2b7b1db851
@ -76,6 +76,9 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
|
|||||||
Dont marked as failed if the error is a "known" transaction warning
|
Dont marked as failed if the error is a "known" transaction warning
|
||||||
"there is already a transaction with the same sender-nonce
|
"there is already a transaction with the same sender-nonce
|
||||||
but higher/same gas price"
|
but higher/same gas price"
|
||||||
|
|
||||||
|
Also don't mark as failed if it has ever been broadcast successfully.
|
||||||
|
A successful broadcast means it may still be mined.
|
||||||
*/
|
*/
|
||||||
const errorMessage = err.message.toLowerCase()
|
const errorMessage = err.message.toLowerCase()
|
||||||
const isKnownTx = (
|
const isKnownTx = (
|
||||||
@ -88,6 +91,7 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
|
|||||||
// other
|
// other
|
||||||
|| errorMessage.includes('gateway timeout')
|
|| errorMessage.includes('gateway timeout')
|
||||||
|| errorMessage.includes('nonce too low')
|
|| errorMessage.includes('nonce too low')
|
||||||
|
|| txMeta.retryCount > 1
|
||||||
)
|
)
|
||||||
// ignore resubmit warnings, return early
|
// ignore resubmit warnings, return early
|
||||||
if (isKnownTx) return
|
if (isKnownTx) return
|
||||||
@ -117,10 +121,12 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
|
|||||||
// Only auto-submit already-signed txs:
|
// Only auto-submit already-signed txs:
|
||||||
if (!('rawTx' in txMeta)) return
|
if (!('rawTx' in txMeta)) return
|
||||||
|
|
||||||
// Increment a try counter.
|
|
||||||
txMeta.retryCount++
|
|
||||||
const rawTx = txMeta.rawTx
|
const rawTx = txMeta.rawTx
|
||||||
return await this.publishTransaction(rawTx)
|
const txHash = await this.publishTransaction(rawTx)
|
||||||
|
|
||||||
|
// Increment successful tries:
|
||||||
|
txMeta.retryCount++
|
||||||
|
return txHash
|
||||||
}
|
}
|
||||||
|
|
||||||
async _checkPendingTx (txMeta) {
|
async _checkPendingTx (txMeta) {
|
||||||
|
Loading…
Reference in New Issue
Block a user