@@ -466,30 +466,37 @@ function addLatencyToHistory(timestamp, latencyMs, isTimeout, isError) {
466466}
467467
468468/**
469- * Update the latency stat displays.
469+ * Update the latency stat displays (if present) .
470470 */
471471function updateLatencyDisplay ( currentLatency , isTimeout , isError ) {
472472 const history = state . latencyHistory ;
473473
474- // Current latency with color coding
474+ // Current latency with color coding (check if element exists)
475475 const currentEl = document . getElementById ( 'latencyCurrent' ) ;
476- currentEl . textContent = formatLatency ( currentLatency ) ;
477- currentEl . className = `latency-value ${ getLatencyClass ( currentLatency , isTimeout ) } ` ;
476+ if ( currentEl ) {
477+ currentEl . textContent = formatLatency ( currentLatency ) ;
478+ currentEl . className = `latency-value ${ getLatencyClass ( currentLatency , isTimeout ) } ` ;
479+ }
478480
479481 // Calculate average
480- if ( history . values . length > 0 ) {
482+ const avgEl = document . getElementById ( 'latencyAverage' ) ;
483+ if ( avgEl && history . values . length > 0 ) {
481484 const avg = history . values . reduce ( ( a , b ) => a + b , 0 ) / history . values . length ;
482- document . getElementById ( 'latencyAverage' ) . textContent = formatLatency ( avg ) ;
485+ avgEl . textContent = formatLatency ( avg ) ;
483486 }
484487
485488 // Calculate max
486- if ( history . values . length > 0 ) {
489+ const maxEl = document . getElementById ( 'latencyMax' ) ;
490+ if ( maxEl && history . values . length > 0 ) {
487491 const max = Math . max ( ...history . values ) ;
488- document . getElementById ( 'latencyMax' ) . textContent = formatLatency ( max ) ;
492+ maxEl . textContent = formatLatency ( max ) ;
489493 }
490494
491495 // Update timeout count
492- document . getElementById ( 'latencyTimeouts' ) . textContent = state . latencyStats . timeoutCount ;
496+ const timeoutsEl = document . getElementById ( 'latencyTimeouts' ) ;
497+ if ( timeoutsEl ) {
498+ timeoutsEl . textContent = state . latencyStats . timeoutCount ;
499+ }
493500}
494501
495502/**
0 commit comments