Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix maximum call stack error in SQL editor (#26434)

Joshen Lim434d7ea74dd1
diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/Results.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/Results.tsx
index 3e3d751c76d..1186c766129 100644
--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/Results.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/Results.tsx
@@ -60,7 +60,10 @@ const Results = ({ id, rows }: { id: string; rows: readonly any[] }) => {
const MAX_COLUMN_WIDTH = 500
const columns: CalculatedColumn<any>[] = Object.keys(rows?.[0] ?? []).map((key, idx) => {
- const maxColumnValueLength = Math.max(...rows.map((row) => String(row[key]).length))
+ const maxColumnValueLength = rows
+ .map((row) => String(row[key]).length)
+ .reduce((a, b) => Math.max(a, b), 0)
+
const columnWidth = Math.max(
Math.min(maxColumnValueLength * EST_CHAR_WIDTH, MAX_COLUMN_WIDTH),
MIN_COLUMN_WIDTH
diff --git a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityTabResults.tsx b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityTabResults.tsx
index 8d9226b2704..dbb6920be32 100644
--- a/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityTabResults.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/UtilityPanel/UtilityTabResults.tsx
@@ -7,6 +7,7 @@ import { useSelectedOrganization } from 'hooks'
import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'
import { useSqlEditorStateSnapshot } from 'state/sql-editor'
import Results from './Results'
+import { Loader2 } from 'lucide-react'
export type UtilityTabResultsProps = {
id: string
@@ -45,8 +46,9 @@ const UtilityTabResults = ({
if (isExecuting) {
return (
- <div className="bg-table-header-light [[data-theme*=dark]_&]:bg-table-header-dark">
- <p className="m-0 border-0 px-6 py-4 font-mono text-sm">Running...</p>
+ <div className="flex items-center gap-x-4 px-6 py-4 bg-table-header-light [[data-theme*=dark]_&]:bg-table-header-dark">
+ <Loader2 size={14} className="animate-spin" />
+ <p className="m-0 border-0 font-mono text-sm">Running...</p>
</div>
)
} else if (result?.error) {
diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx
index 5fae6296f83..2a74810645e 100644
--- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx
+++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureActivity.tsx
@@ -157,10 +157,9 @@ const InfrastructureActivity = () => {
? Number(ioBudgetData.data.slice(-1)[0].disk_io_consumption)
: 0
- const highestIoBudgetConsumption = Math.max(
- ...(ioBudgetData?.data || []).map((x) => Number(x.disk_io_consumption) ?? 0),
- 0
- )
+ const highestIoBudgetConsumption = (ioBudgetData?.data || [])
+ .map((x) => Number(x.disk_io_consumption) ?? 0)
+ .reduce((a, b) => Math.max(a, b), 0)
const chartMeta: { [key: string]: { data: DataPoint[]; isLoading: boolean } } = {
max_cpu_usage: {