From 1b3e0fecfedf0e86d6321620eedac7f2c9815204 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Sun, 18 Jan 2026 18:03:11 +0000 Subject: [PATCH] Add navigation entry fallback in metrics --- src/lib/bundle-metrics.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/lib/bundle-metrics.ts b/src/lib/bundle-metrics.ts index 4c284f3..fdb28fc 100644 --- a/src/lib/bundle-metrics.ts +++ b/src/lib/bundle-metrics.ts @@ -87,7 +87,12 @@ export function analyzePerformance() { return null } - const navigation = performance.getEntriesByType('navigation')[0] as PerformanceNavigationTiming + const navigation = performance.getEntriesByType('navigation')[0] as + | PerformanceNavigationTiming + | undefined + if (!navigation) { + console.warn('[BUNDLE] ⚠️ Navigation performance entry not available') + } const resources = performance.getEntriesByType('resource') as PerformanceResourceTiming[] const jsResources = resources.filter(r => r.name.endsWith('.js')) @@ -97,9 +102,11 @@ export function analyzePerformance() { const totalCssSize = cssResources.reduce((sum, r) => sum + (r.transferSize || 0), 0) const analysis = { - domContentLoaded: navigation.domContentLoadedEventEnd - navigation.fetchStart, - loadComplete: navigation.loadEventEnd - navigation.fetchStart, - ttfb: navigation.responseStart - navigation.fetchStart, + domContentLoaded: navigation + ? navigation.domContentLoadedEventEnd - navigation.fetchStart + : NaN, + loadComplete: navigation ? navigation.loadEventEnd - navigation.fetchStart : NaN, + ttfb: navigation ? navigation.responseStart - navigation.fetchStart : NaN, resources: { js: { count: jsResources.length,