fix: status checks have timeout (#471)
This commit is contained in:
+13
-12
@@ -21,6 +21,7 @@ import { Context as TopUpContext } from './TopUp'
|
|||||||
|
|
||||||
const REFRESH_WHEN_OK = 30_000
|
const REFRESH_WHEN_OK = 30_000
|
||||||
const REFRESH_WHEN_ERROR = 5_000
|
const REFRESH_WHEN_ERROR = 5_000
|
||||||
|
const TIMEOUT = 20_000
|
||||||
|
|
||||||
export enum CheckState {
|
export enum CheckState {
|
||||||
OK = 'OK',
|
OK = 'OK',
|
||||||
@@ -270,7 +271,7 @@ export function Provider({ children }: Props): ReactElement {
|
|||||||
|
|
||||||
// Wrap the chequebook balance call to return BZZ values as Token object
|
// Wrap the chequebook balance call to return BZZ values as Token object
|
||||||
const chequeBalanceWrapper = async () => {
|
const chequeBalanceWrapper = async () => {
|
||||||
const { totalBalance, availableBalance } = await beeDebugApi.getChequebookBalance()
|
const { totalBalance, availableBalance } = await beeDebugApi.getChequebookBalance({ timeout: TIMEOUT })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
totalBalance: new Token(totalBalance),
|
totalBalance: new Token(totalBalance),
|
||||||
@@ -280,14 +281,14 @@ export function Provider({ children }: Props): ReactElement {
|
|||||||
|
|
||||||
// Wrap the balances call to return BZZ values as Token object
|
// Wrap the balances call to return BZZ values as Token object
|
||||||
const peerBalanceWrapper = async () => {
|
const peerBalanceWrapper = async () => {
|
||||||
const { balances } = await beeDebugApi.getAllBalances()
|
const { balances } = await beeDebugApi.getAllBalances({ timeout: TIMEOUT })
|
||||||
|
|
||||||
return balances.map(({ peer, balance }) => ({ peer, balance: new Token(balance) }))
|
return balances.map(({ peer, balance }) => ({ peer, balance: new Token(balance) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wrap the settlements call to return BZZ values as Token object
|
// Wrap the settlements call to return BZZ values as Token object
|
||||||
const settlementsWrapper = async () => {
|
const settlementsWrapper = async () => {
|
||||||
const { totalReceived, settlements, totalSent } = await beeDebugApi.getAllSettlements()
|
const { totalReceived, settlements, totalSent } = await beeDebugApi.getAllSettlements({ timeout: TIMEOUT })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
totalReceived: new Token(totalReceived),
|
totalReceived: new Token(totalReceived),
|
||||||
@@ -303,55 +304,55 @@ export function Provider({ children }: Props): ReactElement {
|
|||||||
const promises = [
|
const promises = [
|
||||||
// API health
|
// API health
|
||||||
beeApi
|
beeApi
|
||||||
.isConnected()
|
.isConnected({ timeout: TIMEOUT })
|
||||||
.then(setApiHealth)
|
.then(setApiHealth)
|
||||||
.catch(() => setApiHealth(false)),
|
.catch(() => setApiHealth(false)),
|
||||||
|
|
||||||
// Debug API health
|
// Debug API health
|
||||||
beeDebugApi
|
beeDebugApi
|
||||||
.getHealth()
|
.getHealth({ timeout: TIMEOUT })
|
||||||
.then(setDebugApiHealth)
|
.then(setDebugApiHealth)
|
||||||
.catch(() => setDebugApiHealth(null)),
|
.catch(() => setDebugApiHealth(null)),
|
||||||
|
|
||||||
// Node Addresses
|
// Node Addresses
|
||||||
beeDebugApi
|
beeDebugApi
|
||||||
.getNodeAddresses()
|
.getNodeAddresses({ timeout: TIMEOUT })
|
||||||
.then(setNodeAddresses)
|
.then(setNodeAddresses)
|
||||||
.catch(() => setNodeAddresses(null)),
|
.catch(() => setNodeAddresses(null)),
|
||||||
|
|
||||||
// NodeInfo
|
// NodeInfo
|
||||||
beeDebugApi
|
beeDebugApi
|
||||||
.getNodeInfo()
|
.getNodeInfo({ timeout: TIMEOUT })
|
||||||
.then(setNodeInfo)
|
.then(setNodeInfo)
|
||||||
.catch(() => setNodeInfo(null)),
|
.catch(() => setNodeInfo(null)),
|
||||||
|
|
||||||
// Network Topology
|
// Network Topology
|
||||||
beeDebugApi
|
beeDebugApi
|
||||||
.getTopology()
|
.getTopology({ timeout: TIMEOUT })
|
||||||
.then(setNodeTopology)
|
.then(setNodeTopology)
|
||||||
.catch(() => setNodeTopology(null)),
|
.catch(() => setNodeTopology(null)),
|
||||||
|
|
||||||
// Peers
|
// Peers
|
||||||
beeDebugApi
|
beeDebugApi
|
||||||
.getPeers()
|
.getPeers({ timeout: TIMEOUT })
|
||||||
.then(setPeers)
|
.then(setPeers)
|
||||||
.catch(() => setPeers(null)),
|
.catch(() => setPeers(null)),
|
||||||
|
|
||||||
// Chequebook address
|
// Chequebook address
|
||||||
beeDebugApi
|
beeDebugApi
|
||||||
.getChequebookAddress()
|
.getChequebookAddress({ timeout: TIMEOUT })
|
||||||
.then(setChequebookAddress)
|
.then(setChequebookAddress)
|
||||||
.catch(() => setChequebookAddress(null)),
|
.catch(() => setChequebookAddress(null)),
|
||||||
|
|
||||||
// Cheques
|
// Cheques
|
||||||
beeDebugApi
|
beeDebugApi
|
||||||
.getLastCheques()
|
.getLastCheques({ timeout: TIMEOUT })
|
||||||
.then(setPeerCheques)
|
.then(setPeerCheques)
|
||||||
.catch(() => setPeerCheques(null)),
|
.catch(() => setPeerCheques(null)),
|
||||||
|
|
||||||
// Chain state
|
// Chain state
|
||||||
beeDebugApi
|
beeDebugApi
|
||||||
.getChainState()
|
.getChainState({ timeout: TIMEOUT })
|
||||||
.then(setChainState)
|
.then(setChainState)
|
||||||
.catch(() => setChainState(null)),
|
.catch(() => setChainState(null)),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user