fix(site): fix error 'Reduce of empty array with no initial value' (#8700)

This commit is contained in:
Bruno Quaresma
2023-07-24 14:17:27 -03:00
committed by GitHub
parent c32085ca10
commit ac973a4b2c
+5 -1
View File
@@ -98,7 +98,11 @@ export const useProxyLatency = (
// This prevents fetching latencies too often.
// 1. Fetch the latest stored latency for the given proxy.
// 2. If the latest latency is after the latestFetchRequest, then skip the latency check.
if (storedLatencies && storedLatencies[proxy.id]) {
if (
storedLatencies &&
storedLatencies[proxy.id] &&
storedLatencies[proxy.id].length > 0
) {
const fetchRequestDate = new Date(latestFetchRequest)
const latest = storedLatencies[proxy.id].reduce((prev, next) =>
prev.at > next.at ? prev : next,