diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index b94178157..607aace6c 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -128,8 +128,8 @@ if ( const federation = { FEDERATION_BACKEND_SEND_ON_API: process.env.FEDERATION_BACKEND_SEND_ON_API ?? '1_0', - FEDERATION_VALIDATE_COMMUNITY_TIMER: - Number(process.env.FEDERATION_VALIDATE_COMMUNITY_TIMER) ?? 60000, + FEDERATION_VALIDATE_COMMUNITY_TIMER: // ?? operator don't work here as expected + Number(process.env.FEDERATION_VALIDATE_COMMUNITY_TIMER) || 60000, FEDERATION_XCOM_SENDCOINS_ENABLED: process.env.FEDERATION_XCOM_SENDCOINS_ENABLED === 'true' ?? false, // default value for community-uuid is equal uuid of stage-3 diff --git a/backend/src/federation/validateCommunities.ts b/backend/src/federation/validateCommunities.ts index f19d606bd..1013db98e 100644 --- a/backend/src/federation/validateCommunities.ts +++ b/backend/src/federation/validateCommunities.ts @@ -13,8 +13,12 @@ import { backendLogger as logger } from '@/server/logger' import { startCommunityAuthentication } from './authenticateCommunities' import { PublicCommunityInfoLoggingView } from './client/1_0/logging/PublicCommunityInfoLogging.view' import { ApiVersionType } from './enum/apiVersionType' +import { LogError } from '@/server/LogError' export async function startValidateCommunities(timerInterval: number): Promise { + if (Number.isNaN(timerInterval) || timerInterval <= 0) { + throw new LogError('FEDERATION_VALIDATE_COMMUNITY_TIMER is not a positive number') + } logger.info( `Federation: startValidateCommunities loop with an interval of ${timerInterval} ms...`, )