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} /> ) },