From 2f4bcca445ecd7799748090b15bbd74de2913a59 Mon Sep 17 00:00:00 2001 From: Vidya Rupak Date: Tue, 23 Dec 2025 15:18:04 -0700 Subject: [PATCH] added a zero check before calculating maxDps, removed height and width from canvas jsx element (dimension conflict) --- .../memory-graph/src/components/graph-canvas.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/memory-graph/src/components/graph-canvas.tsx b/packages/memory-graph/src/components/graph-canvas.tsx index cae74c84..28dd53c7 100644 --- a/packages/memory-graph/src/components/graph-canvas.tsx +++ b/packages/memory-graph/src/components/graph-canvas.tsx @@ -961,11 +961,14 @@ export const GraphCanvas = memo( const MAX_CANVAS_SIZE = 16384 // Calculate effective DPR that keeps us within safe limits - const maxDpr = Math.min( - MAX_CANVAS_SIZE / width, - MAX_CANVAS_SIZE / height, - dpr - ) + // Prevent division by zero by checking for valid dimensions + const maxDpr = width > 0 && height > 0 + ? Math.min( + MAX_CANVAS_SIZE / width, + MAX_CANVAS_SIZE / height, + dpr + ) + : dpr // upscale backing store with clamped dimensions canvas.style.width = `${width}px` @@ -981,7 +984,6 @@ export const GraphCanvas = memo( return ( ( userSelect: "none", WebkitUserSelect: "none", }} - width={width} /> ) },