Skip to content

Commit

Permalink
fix(api-cardano-db-hasura): retry initialization of data fetcher
Browse files Browse the repository at this point in the history
This fetcher can fail on initial startup as it depends on Ogmios being up and running. Retry
this operation using exponential backoff, limited to 15 seconds, indefinitely.
  • Loading branch information
rhyslbw committed Jan 26, 2023
1 parent e6604e9 commit a4e5d62
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/api-cardano-db-hasura/src/HasuraClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,18 @@ export class HasuraClient {
)
})
this.logger.debug({ module: 'HasuraClient' }, 'graphql-engine setup')
await this.adaPotsToCalculateSupplyFetcher.initialize()
await pRetry(async () => {
await this.adaPotsToCalculateSupplyFetcher.initialize()
}, {
factor: 1.1,
forever: true,
maxTimeout: 15000,
onFailedAttempt: util.onFailedAttemptFor(
'Initializing data fetchers',
this.logger
)
})
this.logger.debug({ module: 'HasuraClient' }, 'Data fetchers initialized')
this.state = 'initialized'
this.logger.info({ module: 'HasuraClient' }, 'Initialized')
}
Expand Down

0 comments on commit a4e5d62

Please sign in to comment.