Skip to content

Commit 1ad526a

Browse files
committed
Differentiate if node is stuck too, not just Nexus
1 parent b8bdb93 commit 1ad526a

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

.changelog/1876.bugfix.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve detecting if API is out-of-date

src/app/components/OfflineBanner/hook.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const useIsApiReachable = (
2424
export type FreshnessInfo = {
2525
unavailable?: boolean
2626
outOfDate?: boolean
27-
outOfDateReason?: false | 'indexer' | 'blocks'
27+
outOfDateReason?: false | 'indexer' | 'blocks' | 'node'
2828
lastUpdate?: string
2929
latestBlock?: number
3030
}
@@ -96,7 +96,12 @@ export const useConsensusFreshness = (
9696

9797
const blockInterval = 6 * 1000
9898
const blocksAreBehindNode = data.latest_node_block > data.latest_block + outOfDateThreshold / blockInterval
99-
const outOfDateReason = blocksAreBehindNode ? 'blocks' : freshness.outOfDateReason
99+
const nodeIsOutOfDate = freshness.outOfDate && data.latest_node_block === data.latest_block
100+
const outOfDateReason = blocksAreBehindNode
101+
? 'blocks'
102+
: nodeIsOutOfDate
103+
? 'node'
104+
: freshness.outOfDateReason
100105
return {
101106
...freshness,
102107
outOfDate: outOfDateReason === undefined ? undefined : !!outOfDateReason,

src/app/components/OfflineBanner/index.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export const OfflineBanner: FC<OfflineBannerProps> = props => {
5555
// Don't display lastUpdate. It's updating, but still many blocks behind.
5656
return <StickyAlert severity="warning">{t('home.indexerOutOfDate', { scope })}</StickyAlert>
5757
}
58+
if (outOfDateReason === 'node') {
59+
return <StickyAlert severity="warning">{t('home.nodeOutOfDateSince', { scope, lastUpdate })}</StickyAlert>
60+
}
5861
exhaustedTypeWarning('Unexpected outOfDateReason', outOfDateReason)
5962
return <StickyAlert severity="warning">{t('home.indexerOutOfDate', { scope })}</StickyAlert>
6063
}

src/locales/en/translation.json

+1
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@
624624
"userOffline": "You are offline. We’re trying to reconnect",
625625
"indexerOutOfDate": "We don't have fully up-to-date data about our {{ scope }}. The data displayed here might be out of date.",
626626
"indexerOutOfDateSince": "The last update we have about our {{ scope }} is from {{ lastUpdate }}. The data displayed here might be out of date.",
627+
"nodeOutOfDateSince": "The explorer's gRPC node has not observed new blocks since {{ lastUpdate }}. Check status.oasis.io.",
627628
"indexerUnavailable": "Data about {{ scope }} is currently not available. Please check back later.",
628629
"blocks": "Blocks",
629630
"exploreBtnText": "Explore Oasis",

0 commit comments

Comments
 (0)