From 700b67527154e7a3d3ec857da428b6e980a921f3 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Tue, 12 Nov 2024 17:56:56 +0000 Subject: [PATCH 1/2] check if rpcs and indexer_networks are aligned, log --- src/utils/config.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/utils/config.ts b/src/utils/config.ts index 9e85d0f48..bc0d5e76c 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -102,9 +102,12 @@ function getSupportedChains(): RPCS | null { function getIndexingNetworks(supportedNetworks: RPCS): RPCS | null { const indexerNetworksEnv = process.env.INDEXER_NETWORKS + + const defaultErrorMsg = + 'Missing or invalid "INDEXER_NETWORKS" variable. Running Indexer with all supported networks defined in RPCS env variable...' if (!indexerNetworksEnv) { CONFIG_LOGGER.logMessageWithEmoji( - 'INDEXER_NETWORKS is not defined, running Indexer with all supported networks defined in RPCS env variable ...', + defaultErrorMsg, true, GENERIC_EMOJIS.EMOJI_CHECK_MARK, LOG_LEVELS_STR.LEVEL_INFO @@ -114,9 +117,10 @@ function getIndexingNetworks(supportedNetworks: RPCS): RPCS | null { try { const indexerNetworks: number[] = JSON.parse(indexerNetworksEnv) + // env var exists but is wrong, so it does not index anything, but we still log the error if (indexerNetworks.length === 0) { CONFIG_LOGGER.logMessageWithEmoji( - 'INDEXER_NETWORKS is an empty array, Running node without the Indexer component...', + '"INDEXER_NETWORKS" is an empty array, Running node without the Indexer component...', true, GENERIC_EMOJIS.EMOJI_CROSS_MARK, LOG_LEVELS_STR.LEVEL_ERROR @@ -132,10 +136,19 @@ function getIndexingNetworks(supportedNetworks: RPCS): RPCS | null { return acc }, {}) + // if variables are not aligned we might end up not running indexer at all, so at least we should log a warning + if (Object.keys(filteredNetworks).length === 0) { + CONFIG_LOGGER.logMessageWithEmoji( + '"RPCS" and "INDEXER_NETWORKS" env variables are not aligned! Running node without the Indexer component...', + true, + GENERIC_EMOJIS.EMOJI_CROSS_MARK, + LOG_LEVELS_STR.LEVEL_ERROR + ) + } return filteredNetworks } catch (e) { CONFIG_LOGGER.logMessageWithEmoji( - 'Missing or Invalid INDEXER_NETWORKS env variable format,running Indexer with all supported networks defined in RPCS env variable ...', + defaultErrorMsg, true, GENERIC_EMOJIS.EMOJI_CROSS_MARK, LOG_LEVELS_STR.LEVEL_ERROR From 20a41a8553d85e7db988aa20ab95d2b79223076a Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Wed, 13 Nov 2024 09:08:17 +0000 Subject: [PATCH 2/2] improve log msg if network env vars mismatch --- src/utils/config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/config.ts b/src/utils/config.ts index bc0d5e76c..bc659edcf 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -139,7 +139,9 @@ function getIndexingNetworks(supportedNetworks: RPCS): RPCS | null { // if variables are not aligned we might end up not running indexer at all, so at least we should log a warning if (Object.keys(filteredNetworks).length === 0) { CONFIG_LOGGER.logMessageWithEmoji( - '"RPCS" and "INDEXER_NETWORKS" env variables are not aligned! Running node without the Indexer component...', + `"RPCS" chains: "${Object.keys( + supportedNetworks + )}" and "INDEXER_NETWORKS" chains: "${indexerNetworks}" mismatch! Running node without the Indexer component...`, true, GENERIC_EMOJIS.EMOJI_CROSS_MARK, LOG_LEVELS_STR.LEVEL_ERROR