From 9f8dba227c95706ca3527bd48d381e7622cc0a5e Mon Sep 17 00:00:00 2001 From: Tudor Date: Sun, 5 Jul 2026 23:07:52 +0100 Subject: [PATCH] fix(compare): keep chart data when a client refetch fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The compare view refetches /api/compare on the client after SSR; on any failure the catch nulled comparisonData, destroying the working SSR-provided chart. A transient error (or staging's broken external /api proxy) should not blank a comparison the user is already viewing — keep the existing data instead. Co-Authored-By: Claude Fable 5 --- nextjs-app/components/ComparisonView.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nextjs-app/components/ComparisonView.tsx b/nextjs-app/components/ComparisonView.tsx index 047d3b5..e1f929d 100644 --- a/nextjs-app/components/ComparisonView.tsx +++ b/nextjs-app/components/ComparisonView.tsx @@ -111,8 +111,10 @@ export function ComparisonView({ setComparisonData(data.comparison); }) .catch((err) => { + // Keep whatever we already have (SSR data or a previous fetch) rather + // than blanking the chart — a transient refetch failure shouldn't + // destroy a working comparison the user is looking at. console.error('Failed to fetch comparison:', err); - setComparisonData(null); }); } else { setComparisonData(null);