File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,9 +64,11 @@ export function usePerformanceData() {
6464 const [ loading , setLoading ] = useState ( true )
6565 const [ error , setError ] = useState < string | null > ( null )
6666 const mountedRef = React . useRef ( true )
67+ const refetchingRef = React . useRef ( false )
6768
6869 const refetch = useCallback ( async ( ) => {
69- if ( ! mountedRef . current ) return
70+ if ( ! mountedRef . current || refetchingRef . current ) return
71+ refetchingRef . current = true
7072 setLoading ( true )
7173 setError ( null )
7274 try {
@@ -91,6 +93,8 @@ export function usePerformanceData() {
9193 if ( mountedRef . current ) setMetricsInfo ( ( metricsRes as MetricsInfo ) ?? { } )
9294 } catch {
9395 if ( mountedRef . current ) setMetricsInfo ( { } )
96+ } finally {
97+ refetchingRef . current = false
9498 }
9599 } , [ systemApi , t ] )
96100
Original file line number Diff line number Diff line change @@ -30,16 +30,16 @@ export function useSystem() {
3030
3131 const getSystemMetrics = useCallback ( async ( ) => {
3232 try {
33- let merged : Record < string , unknown > = { }
34- for await ( const data of api . streamRequest ( "/metrics" ) ) {
35- merged = { ...merged , ...data }
36- }
37- if ( Object . keys ( merged ) . length > 0 ) return merged
33+ return await api . get ( "/metrics" , {
34+ params : {
35+ n : "1" ,
36+ types : "1" ,
37+ } ,
38+ } )
3839 } catch {
39- // Fallback: try regular GET if streaming fails (e.g. API returns single JSON)
40+ // Keep page rendering resilient when metrics endpoint is temporarily unavailable.
4041 }
41- const res = await api . get ( "/metrics" )
42- return ( res as Record < string , unknown > ) ?? { }
42+ return { }
4343 } , [ api ] )
4444
4545 const getLicense = useCallback ( async ( ) => {
You can’t perform that action at this time.
0 commit comments