Skip to content

Commit

Permalink
fix(fiatconnect): avoid allowing user to retry if tx might still be p…
Browse files Browse the repository at this point in the history
…ending (#3400)

### Description

We've seen a case in testing where a user got this error in their logs
```
info [2023-01-23T17:15:17.387Z] FiatConnectSaga :: Transaction failed: c2ba9fc0-4f75-4526-b383-b59e947fc981 :: Failed to check for transaction receipt:
{} in _fireError@/private/var/containers/Bundle/Application/DA4D4DB7-095F-4CFC-A18B-4162D7E9283D/celo.app/ :: network connected true
```
and was presented with the option to retry the FiatConnect transfer, but
when they retried, they ended up with 2 transfers.

If we get that tx error, we should avoid allowing the user to retry
their transfer, since it may still be confirmed.

### Test plan

unit tested. not sure we can reproduce this one manually.

### Related issues

na

### Backwards compatibility

yes
  • Loading branch information
cajubelt authored Jan 25, 2023
1 parent 1543784 commit a95cab8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/transactions/send.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ describe('isTxPossiblyPending', () => {
const result = isTxPossiblyPending(new Error('nonce too low error!!!'))
expect(result).toBe(true)
})
it('returns true when failed to check for tx receipt', () => {
const result = isTxPossiblyPending(new Error('Failed to check for transaction receipt:\n{}')) // error message copied from user's logs
expect(result).toBe(true)
})
it('returns false when error is unrelated', () => {
const result = isTxPossiblyPending(new Error('some unrelated error!!!'))
expect(result).toBe(false)
Expand Down
9 changes: 9 additions & 0 deletions src/transactions/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const NONCE_TOO_LOW_ERROR = 'nonce too low'
const OUT_OF_GAS_ERROR = 'out of gas'
const ALWAYS_FAILING_ERROR = 'always failing transaction'
const KNOWN_TX_ERROR = 'known transaction'
const CHECK_FOR_TX_RECEIPT_ERROR = 'failed to check for transaction receipt'

// 90s. Maximum total time to wait for confirmation when sending a transaction. (Includes grace period)
const TX_TIMEOUT = 90000
Expand Down Expand Up @@ -355,6 +356,14 @@ export function isTxPossiblyPending(err: any): boolean {
)
return true
}

if (message.includes(CHECK_FOR_TX_RECEIPT_ERROR)) {
Logger.error(
`${TAG}@isTxPossiblyPending`,
'Failed to check for tx receipt, but tx still might be confirmed. Will not reattempt'
)
return true
}
return false
}

Expand Down

0 comments on commit a95cab8

Please sign in to comment.