@@ -102,9 +102,12 @@ function getSupportedChains(): RPCS | null {
102102
103103function getIndexingNetworks ( supportedNetworks : RPCS ) : RPCS | null {
104104 const indexerNetworksEnv = process . env . INDEXER_NETWORKS
105+
106+ const defaultErrorMsg =
107+ 'Missing or invalid "INDEXER_NETWORKS" variable. Running Indexer with all supported networks defined in RPCS env variable...'
105108 if ( ! indexerNetworksEnv ) {
106109 CONFIG_LOGGER . logMessageWithEmoji (
107- 'INDEXER_NETWORKS is not defined, running Indexer with all supported networks defined in RPCS env variable ...' ,
110+ defaultErrorMsg ,
108111 true ,
109112 GENERIC_EMOJIS . EMOJI_CHECK_MARK ,
110113 LOG_LEVELS_STR . LEVEL_INFO
@@ -114,9 +117,10 @@ function getIndexingNetworks(supportedNetworks: RPCS): RPCS | null {
114117 try {
115118 const indexerNetworks : number [ ] = JSON . parse ( indexerNetworksEnv )
116119
120+ // env var exists but is wrong, so it does not index anything, but we still log the error
117121 if ( indexerNetworks . length === 0 ) {
118122 CONFIG_LOGGER . logMessageWithEmoji (
119- 'INDEXER_NETWORKS is an empty array, Running node without the Indexer component...' ,
123+ '" INDEXER_NETWORKS" is an empty array, Running node without the Indexer component...' ,
120124 true ,
121125 GENERIC_EMOJIS . EMOJI_CROSS_MARK ,
122126 LOG_LEVELS_STR . LEVEL_ERROR
@@ -132,10 +136,21 @@ function getIndexingNetworks(supportedNetworks: RPCS): RPCS | null {
132136 return acc
133137 } , { } )
134138
139+ // if variables are not aligned we might end up not running indexer at all, so at least we should log a warning
140+ if ( Object . keys ( filteredNetworks ) . length === 0 ) {
141+ CONFIG_LOGGER . logMessageWithEmoji (
142+ `"RPCS" chains: "${ Object . keys (
143+ supportedNetworks
144+ ) } " and "INDEXER_NETWORKS" chains: "${ indexerNetworks } " mismatch! Running node without the Indexer component...`,
145+ true ,
146+ GENERIC_EMOJIS . EMOJI_CROSS_MARK ,
147+ LOG_LEVELS_STR . LEVEL_ERROR
148+ )
149+ }
135150 return filteredNetworks
136151 } catch ( e ) {
137152 CONFIG_LOGGER . logMessageWithEmoji (
138- 'Missing or Invalid INDEXER_NETWORKS env variable format,running Indexer with all supported networks defined in RPCS env variable ...' ,
153+ defaultErrorMsg ,
139154 true ,
140155 GENERIC_EMOJIS . EMOJI_CROSS_MARK ,
141156 LOG_LEVELS_STR . LEVEL_ERROR
0 commit comments