fix: only bind cluster stats on working connections (#18763)
This commit is contained in:
parent
6abafac479
commit
d9970c0a7d
|
@ -74,6 +74,13 @@ const PerformanceContext = React.createContext<PerformanceState | undefined>(
|
|||
);
|
||||
|
||||
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 () => {
|
||||
|
|
Loading…
Reference in New Issue