diff --git a/explorer/src/providers/stats/solanaClusterStats.tsx b/explorer/src/providers/stats/solanaClusterStats.tsx index 8672d0f22f..babd477d86 100644 --- a/explorer/src/providers/stats/solanaClusterStats.tsx +++ b/explorer/src/providers/stats/solanaClusterStats.tsx @@ -74,6 +74,13 @@ const PerformanceContext = React.createContext( ); type Props = { children: React.ReactNode }; + +function getConnection(url: string): Connection | undefined { + try { + return new Connection(url); + } catch (error) {} +} + export function SolanaClusterStatsProvider({ children }: Props) { const { cluster, url } = useCluster(); const [active, setActive] = React.useState(false); @@ -89,7 +96,10 @@ export function SolanaClusterStatsProvider({ children }: Props) { React.useEffect(() => { if (!active || !url) return; - const connection = new Connection(url); + const connection = getConnection(url); + + if (!connection) return; + let lastSlot: number | null = null; const getPerformanceSamples = async () => {