Skip to content

Commit ac973a4

Browse files
fix(site): fix error 'Reduce of empty array with no initial value' (#8700)
1 parent c32085c commit ac973a4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

site/src/contexts/useProxyLatency.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ export const useProxyLatency = (
9898
// This prevents fetching latencies too often.
9999
// 1. Fetch the latest stored latency for the given proxy.
100100
// 2. If the latest latency is after the latestFetchRequest, then skip the latency check.
101-
if (storedLatencies && storedLatencies[proxy.id]) {
101+
if (
102+
storedLatencies &&
103+
storedLatencies[proxy.id] &&
104+
storedLatencies[proxy.id].length > 0
105+
) {
102106
const fetchRequestDate = new Date(latestFetchRequest)
103107
const latest = storedLatencies[proxy.id].reduce((prev, next) =>
104108
prev.at > next.at ? prev : next,

0 commit comments

Comments
 (0)