fix: only bind cluster stats on working connections (#18763)
This commit is contained in:
@ -74,6 +74,13 @@ const PerformanceContext = React.createContext<PerformanceState | undefined>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
type Props = { children: React.ReactNode };
|
type Props = { children: React.ReactNode };
|
||||||
|
|
||||||
|
function getConnection(url: string): Connection | undefined {
|
||||||
|
try {
|
||||||
|
return new Connection(url);
|
||||||
|
} catch (error) {}
|
||||||
|
}
|
||||||
|
|
||||||
export function SolanaClusterStatsProvider({ children }: Props) {
|
export function SolanaClusterStatsProvider({ children }: Props) {
|
||||||
const { cluster, url } = useCluster();
|
const { cluster, url } = useCluster();
|
||||||
const [active, setActive] = React.useState(false);
|
const [active, setActive] = React.useState(false);
|
||||||
@ -89,7 +96,10 @@ export function SolanaClusterStatsProvider({ children }: Props) {
|
|||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!active || !url) return;
|
if (!active || !url) return;
|
||||||
|
|
||||||
const connection = new Connection(url);
|
const connection = getConnection(url);
|
||||||
|
|
||||||
|
if (!connection) return;
|
||||||
|
|
||||||
let lastSlot: number | null = null;
|
let lastSlot: number | null = null;
|
||||||
|
|
||||||
const getPerformanceSamples = async () => {
|
const getPerformanceSamples = async () => {
|
||||||
|
Reference in New Issue
Block a user