From e69c7f0b5bfa65cc4a66f52f632953fb7870920d Mon Sep 17 00:00:00 2001 From: Alex Stelea Date: Fri, 26 Jul 2024 14:13:46 +0100 Subject: [PATCH] fix: retry FailedToFetch --- .../src/modules/gateway/gateway.module.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/dapp-toolkit/src/modules/gateway/gateway.module.ts b/packages/dapp-toolkit/src/modules/gateway/gateway.module.ts index 75f6de9e..a6f2ae8f 100644 --- a/packages/dapp-toolkit/src/modules/gateway/gateway.module.ts +++ b/packages/dapp-toolkit/src/modules/gateway/gateway.module.ts @@ -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, @@ -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', - }, + }), ) }) }),