Skip to content

Commit

Permalink
Fix/cannot read networksynchronization (#874)
Browse files Browse the repository at this point in the history
* fix: fixed network issue which results in an empty ogmios status

* fix: checking if serverhealth is initialized or not

* fix: checking if serverhealth is initialized or not

* fix: checking if serverhealth is initialized or not

* fix: checking if serverhealth is initialized or not
  • Loading branch information
Kammerlo committed Jun 7, 2024
1 parent 97babf4 commit 34d73ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ ENV \
LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" \
METADATA_SERVER_URI=${METADATA_SERVER_URI} \
OGMIOS_HOST="cardano-node-ogmios" \
OGMIOS_PORT=1337 \
POSTGRES_DB_FILE=/run/secrets/postgres_db \
POSTGRES_HOST=postgres \
POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password \
Expand All @@ -98,7 +99,8 @@ ENV \
HASURA_URI="http://hasura:8080" \
LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" \
NETWORK=${NETWORK} \
OGMIOS_HOST="cardano-node-ogmios"
OGMIOS_HOST="cardano-node-ogmios" \
OGMIOS_PORT=1337
COPY --from=cardano-graphql-builder /app/packages/api-cardano-db-hasura/dist /app/packages/api-cardano-db-hasura/dist
COPY --from=cardano-graphql-builder /app/packages/api-cardano-db-hasura/hasura/project /app/packages/api-cardano-db-hasura/hasura/project
COPY --from=cardano-graphql-builder /app/packages/api-cardano-db-hasura/package.json /app/packages/api-cardano-db-hasura/package.json
Expand Down
11 changes: 8 additions & 3 deletions packages/api-cardano-db-hasura/src/CardanoNodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ export class CardanoNodeClient {
this.serverHealthFetcher = this.serverHealthFetcher || new DataFetcher(
'ServerHealth',
() => getServerHealth({ connection: createConnectionObject(ogmiosConnectionConfig) }),
30000, this.logger
5000, this.logger
)
await pRetry(async () => {
await this.serverHealthFetcher.initialize()
try {
await this.serverHealthFetcher.initialize()
} catch (e) {
this.logger.info('Waiting for Ogmios to be ready...')
throw e
}
}, {
factor: 1.2,
retries: 3,
retries: 100,
onFailedAttempt: util.onFailedAttemptFor(
'Establishing connection to Ogmios server',
this.logger
Expand Down
6 changes: 5 additions & 1 deletion packages/util/src/data_fetching/DataFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export class DataFetcher<DataValue> {
this.fetch = async () => {
if (this.isFetching) return
this.isFetching = true
this.value = await fetchFn()
try {
this.value = await fetchFn()
} catch (e) {
this.logger.debug('Tried fetching...')
}
this.isFetching = false
}
}
Expand Down

0 comments on commit 34d73ff

Please sign in to comment.