From 2178c1eb1f70c0c47ca42115550fd2406903c98d Mon Sep 17 00:00:00 2001 From: ikprk Date: Wed, 29 May 2024 10:58:08 +0200 Subject: [PATCH] CR fixes --- src/mail-scheduler/index.ts | 2 ++ src/processor.ts | 2 +- src/utils/joystreamPrice.ts | 11 ++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mail-scheduler/index.ts b/src/mail-scheduler/index.ts index 36fe3e50f..c96cc6dbd 100644 --- a/src/mail-scheduler/index.ts +++ b/src/mail-scheduler/index.ts @@ -5,6 +5,7 @@ import { ConfigVariable, config } from '../utils/config' import { uniqueId } from '../utils/crypto' import { globalEm } from '../utils/globalEm' import { createMailContent, executeMailDelivery } from './utils' +import { updateJoystreamPrice } from '../utils/joystreamPrice' export async function getMaxAttempts(em: EntityManager): Promise { const maxAttempts = await config.get(ConfigVariable.EmailNotificationDeliveryMaxAttempts, em) @@ -31,6 +32,7 @@ export async function mailsToDeliver(em: EntityManager): Promise undefined) - .catch(() => ctx.log.error('Fetching JOYSTREAM price failed')) + .catch(() => undefined) } const overlay = await EntityManagerOverlay.create(ctx.store, afterDbUpdate) diff --git a/src/utils/joystreamPrice.ts b/src/utils/joystreamPrice.ts index 26017b5a7..2bea5e99f 100644 --- a/src/utils/joystreamPrice.ts +++ b/src/utils/joystreamPrice.ts @@ -10,9 +10,14 @@ const MAX_SAFE_NUMBER_BN = new BN(Number.MAX_SAFE_INTEGER) const log = createLogger('price') export const updateJoystreamPrice = async () => { - const data = await fetch('https://status.joystream.org/price') - const json = await data.json() - JOYSTREAM_USD_PRICE = +json.price ?? 0 + // we don't care if the request fails, app should continue to work w/o joy price + const data = await fetch('https://status.joystream.org/price').catch(() => + log.error('Fetching JOYSTREAM price failed') + ) + if (data) { + const json = await data.json() + JOYSTREAM_USD_PRICE = +json.price ?? 0 + } } export const schedulePriceUpdate = async (): Promise => {