Skip to content

Commit

Permalink
handle undefined string (#5241)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecsavvy committed May 16, 2023
1 parent a72f0f7 commit 8866f2c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions monitoring/healthz/src/DiscoveryHealth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,18 @@ function HealthRow({ isContent, sp }: { isContent: boolean; sp: SP }) {
bytesToGb(health.database_size) || bytesToGb(health.databaseSize)
const autoUpgradeEnabled =
health.auto_upgrade_enabled || health.autoUpgradeEnabled
const getPeers = (str: string) => {
const getPeers = (str: string | undefined) => {
if (str === undefined) return "chain health undefined"
const match = str.match(/Peers: (.)/)
return (match && match[1]) ? match[1] : "no peers found"
}
const getProducing = (str: string) => {
const getProducing = (str: string | undefined) => {
if (str === undefined) return "chain health undefined"
return (!str.includes("The node stopped producing blocks.")).toString()
}
// currently discprov does not expose the address of its internal chain instance
const isSigner = (str: string) => getProducing(str)
const chainDescription = health.chain_health?.entries["node-health"].description
const isSigner = (str: string | undefined) => getProducing(str)
const chainDescription: string = health.chain_health?.entries["node-health"].description

return (
<tr>
Expand Down

0 comments on commit 8866f2c

Please sign in to comment.