From 9485400fd4d2513fd82b6f0d1c52c4169163a49a Mon Sep 17 00:00:00 2001 From: Zach Lite Date: Thu, 20 Apr 2023 20:45:03 +0000 Subject: [PATCH] ui: fix linegraph render for large clusters We were feeding `Math.min` and `Math.max` very large arrays (length equal to ~10e7). These functions take variadic arguments, and the runtime can't handle that many arguments. As a result we blow the stack, causing uncaught range errors. Instead, we'll use lodash min and max which are not variadic. Resolves https://github.com/cockroachdb/cockroach/issues/101377 Epic: None Release note: None --- pkg/ui/workspaces/cluster-ui/src/graphs/utils/domain.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/ui/workspaces/cluster-ui/src/graphs/utils/domain.ts b/pkg/ui/workspaces/cluster-ui/src/graphs/utils/domain.ts index 37fd4728aa05..eba1b12fbe5c 100644 --- a/pkg/ui/workspaces/cluster-ui/src/graphs/utils/domain.ts +++ b/pkg/ui/workspaces/cluster-ui/src/graphs/utils/domain.ts @@ -307,10 +307,7 @@ export function calculateYAxisDomain( data: number[], ): AxisDomain { const allDatapoints = data.concat([0, 1]); - const yExtent = [ - Math.min(...allDatapoints), - Math.max(...allDatapoints), - ] as Extent; + const yExtent = [_.min(allDatapoints), _.max(allDatapoints)] as Extent; switch (axisUnits) { case AxisUnits.Bytes: