Skip to content

Commit

Permalink
fix: retry FailedToFetch
Browse files Browse the repository at this point in the history
  • Loading branch information
xstelea committed Jul 26, 2024
1 parent de8b9ad commit e69c7f0
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/dapp-toolkit/src/modules/gateway/gateway.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GatewayApiService } from './gateway.service'
import type { Result } from 'neverthrow'
import { ResultAsync, err } from 'neverthrow'
import { ResultAsync, err, ok } from 'neverthrow'
import { filter, first, firstValueFrom, switchMap } from 'rxjs'
import {
ExponentialBackoffInput,
Expand Down Expand Up @@ -63,27 +63,24 @@ export const GatewayModule = (input: {
retry.trigger.next()
return
})
.mapErr((response) => {
.orElse((response) => {
if (response.reason === 'FailedToFetch') {
logger?.debug({
error: response,
context: 'unexpected error, retrying',
})
retry.trigger.next()
return
return ok(undefined)
}

logger?.debug(response)
return SdkError(
'failedToPollSubmittedTransaction',
'',
undefined,
{
return err(
SdkError('failedToPollSubmittedTransaction', '', undefined, {
error: response,
transactionIntentHash,
context:
'GatewayModule.pollTransactionStatus.getTransactionStatus',
},
}),
)
})
}),
Expand Down

0 comments on commit e69c7f0

Please sign in to comment.