Skip to content

Commit

Permalink
chore(apps/whale-api): add 15 seconds timeout to ModelProbeIndicator.…
Browse files Browse the repository at this point in the history
…liveness (#1903)

#### What this PR does / why we need it:

As per the title.

Why? Because `this.block.getHighest()` doesn't have a timeout, it can
run forever.
  • Loading branch information
fuxingloh authored Dec 5, 2022
1 parent 43cd88a commit 35649d3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/whale-api/src/module.model/_model.probes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export class ModelProbeIndicator extends ProbeIndicator {
*/
async liveness (): Promise<HealthIndicatorResult> {
try {
await this.block.getHighest()
await Promise.race([
this.block.getHighest(),
new Promise((resolve, reject) => setTimeout(() => reject(new Error('model.timeout')), 15000))
])
} catch (err) {
return this.withDead('model', 'unable to get the latest block')
}
Expand Down

0 comments on commit 35649d3

Please sign in to comment.