From 4de2a7fa8ea7616943d0ca2a012aee7e22c25933 Mon Sep 17 00:00:00 2001 From: NixReaper Date: Sat, 11 Apr 2026 14:19:24 -0500 Subject: [PATCH] fix: auto-retry version fetch + add uptime/kill to exec allowlist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Layout.tsx: when versionError is true, automatically retry fetchVersion after 5 s. This handles the case where the initial fetch runs during the service-restart window after an upgrade (server not yet up), which caused the sidebar footer to permanently show 'Version unavailable' even though the server came back online shortly after. exec.ts: add 'uptime' and 'kill' to ALLOWED_COMMANDS. 'uptime' was missing, causing exec('uptime', ['-p']) in GET /api/nixserver/system/info to throw 'Command not allowed', which rejected the entire Promise.all and returned 500 — leaving Hostname and OS as '...' on the dashboard. --- nixserver/src/components/Layout.tsx | 8 ++++++++ server/src/core/exec.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nixserver/src/components/Layout.tsx b/nixserver/src/components/Layout.tsx index 643e471..7e9d3df 100644 --- a/nixserver/src/components/Layout.tsx +++ b/nixserver/src/components/Layout.tsx @@ -475,8 +475,16 @@ export default function Layout() { } }, []) + // Initial fetch useEffect(() => { fetchVersion() }, [fetchVersion]) + // Auto-retry every 5 s while in error state (handles the service-restart window after an upgrade) + useEffect(() => { + if (!versionError) return + const t = setTimeout(fetchVersion, 5_000) + return () => clearTimeout(t) + }, [versionError, fetchVersion]) + const handleUpgrade = async () => { if (upgradeState === 'confirm') { setUpgradeState('running') diff --git a/server/src/core/exec.ts b/server/src/core/exec.ts index dbfa3a6..60116a6 100644 --- a/server/src/core/exec.ts +++ b/server/src/core/exec.ts @@ -24,7 +24,7 @@ const ALLOWED_COMMANDS = new Set([ // Network 'ss', 'ip', 'hostname', // System - 'uname', 'free', 'ps', + 'uname', 'uptime', 'free', 'ps', 'kill', // PHP 'php8.2', 'php8.3', // Fail2ban