Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix: CLI tools page hangs — add timeout to runtime status checks

diegosouzapwfb840d63929b
diff --git a/src/app/(dashboard)/dashboard/cli-tools/CLIToolsPageClient.tsx b/src/app/(dashboard)/dashboard/cli-tools/CLIToolsPageClient.tsx
index d560e8e88b..93717ab677 100644
--- a/src/app/(dashboard)/dashboard/cli-tools/CLIToolsPageClient.tsx
+++ b/src/app/(dashboard)/dashboard/cli-tools/CLIToolsPageClient.tsx
@@ -66,13 +66,17 @@ export default function CLIToolsPageClient({ machineId }) {
const fetchToolStatuses = async () => {
try {
- const res = await fetch("/api/cli-tools/status");
+ const controller = new AbortController();
+ const timeoutId = setTimeout(() => controller.abort(), 8000); // 8s client timeout
+ const res = await fetch("/api/cli-tools/status", { signal: controller.signal });
+ clearTimeout(timeoutId);
if (res.ok) {
const data = await res.json();
setToolStatuses(data || {});
}
} catch (error) {
- console.log("Error fetching CLI tool statuses:", error);
+ // Timeout or network error — proceed without statuses
+ console.log("CLI tool status check timed out or failed:", error);
} finally {
setStatusesLoaded(true);
}
diff --git a/src/app/api/cli-tools/status/route.ts b/src/app/api/cli-tools/status/route.ts
index 610ba837f5..877cabd117 100644
--- a/src/app/api/cli-tools/status/route.ts
+++ b/src/app/api/cli-tools/status/route.ts
@@ -53,11 +53,23 @@ export async function GET() {
try {
const statuses = {};
- // Run all runtime checks in parallel
+ // Run all runtime checks in parallel with individual timeouts
+ const RUNTIME_CHECK_TIMEOUT = 5000; // 5s per tool max
await Promise.all(
CLI_TOOL_IDS.map(async (toolId) => {
try {
- const runtime = await getCliRuntimeStatus(toolId);
+ const runtime = (await Promise.race([
+ getCliRuntimeStatus(toolId),
+ new Promise((_, reject) =>
+ setTimeout(() => reject(new Error("Timeout")), RUNTIME_CHECK_TIMEOUT)
+ ),
+ ])) as {
+ installed: boolean;
+ runnable: boolean;
+ command?: string;
+ commandPath?: string;
+ reason?: string;
+ };
statuses[toolId] = {
installed: runtime.installed,
runnable: runtime.runnable,
@@ -69,7 +81,7 @@ export async function GET() {
statuses[toolId] = {
installed: false,
runnable: false,
- reason: error.message,
+ reason: error.message || "Check failed",
};
}
})