diff --git a/packages/cardano-services/src/Asset/DbSyncAssetProvider.ts b/packages/cardano-services/src/Asset/DbSyncAssetProvider.ts index f90e5a8c55d..5c7fd8fb994 100644 --- a/packages/cardano-services/src/Asset/DbSyncAssetProvider.ts +++ b/packages/cardano-services/src/Asset/DbSyncAssetProvider.ts @@ -72,8 +72,9 @@ export class DbSyncAssetProvider extends DbSyncProvider implements AssetProvider } catch (error) { if (error instanceof ProviderError && error.reason === ProviderFailure.ConnectionFailure) { assetInfo.tokenMetadata = undefined; + } else { + throw error; } - throw error; } } diff --git a/packages/cardano-services/test/Asset/DbSyncAssetProvider.test.ts b/packages/cardano-services/test/Asset/DbSyncAssetProvider.test.ts index d3691049b6f..cbd75315321 100644 --- a/packages/cardano-services/test/Asset/DbSyncAssetProvider.test.ts +++ b/packages/cardano-services/test/Asset/DbSyncAssetProvider.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-shadow */ import { Asset, Cardano, ProviderError, ProviderFailure } from '@cardano-sdk/core'; import { CardanoTokenRegistry, @@ -82,4 +83,20 @@ describe('DbSyncAssetProvider', () => { name: 'macaron cake token' }); }); + + it('returns undefined asset token metadata if the token registry throws a network error', async () => { + const { tokenMetadataServerUrl, closeMock } = await mockTokenRegistry(() => ({ body: {}, code: 500 })); + const tokenMetadataService = new CardanoTokenRegistry({ logger }, { tokenMetadataServerUrl }); + + provider = new DbSyncAssetProvider({ db, logger, ntfMetadataService, tokenMetadataService }); + + const asset = await provider.getAsset({ + assetId: validAssetId, + extraData: { tokenMetadata: true } + }); + + expect(asset.tokenMetadata).toBeUndefined(); + tokenMetadataService.shutdown(); + await closeMock(); + }); });