Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/dashboard/next-14.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ocean committed Nov 29, 2024
2 parents b41c18c + 8358d8e commit e5f3efb
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -132,10 +136,21 @@ 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" 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
)
}
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
Expand Down

0 comments on commit e5f3efb

Please sign in to comment.