Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(standardize): fix timeout race condition and increase default to 180s
Adam Eivy080753561013
diff --git a/.changelog/v0.13.x.md b/.changelog/v0.13.x.mdindex 90475a5d97..bf6e06fd2b 100644--- a/.changelog/v0.13.x.md+++ b/.changelog/v0.13.x.md@@ -114,3 +114,9 @@ This release expands the genome dashboard with comprehensive cancer predispositi- Removed `git-maintenance` skill template; consolidated local repo checks (uncommitted changes, stale branches) into the `github-repo-maintenance` skill template- **Enabled `job-github-repo-maintenance`** — activated the unified GitHub repo maintenance job for weekly automated audits covering security alerts, stale dependencies, missing CI/README/license, uncommitted local changes, and stale branches- Cleaned up stale `job-git-maintenance` data entry left behind after the merge++### PM2 Standardizer Reliability+- **Fixed timeout race condition** in `executeCliAnalysis` — the promise could be rejected twice (once by timeout, once by the killed child's close event); now uses a `settled` guard and clears the timer on completion+- **Increased default timeout** from 120s to 180s for both CLI and API providers — CLI LLM analysis of projects without existing ecosystem configs often exceeds 2 minutes+- **Added API fetch timeout** — `executeApiAnalysis` now uses `AbortController` with the same provider timeout, preventing indefinite hangs on unresponsive API endpoints+- **Added timing diagnostics** — `analyzeApp` now logs the provider name, type, and elapsed time for each analysis, making slow provider issues easier to diagnosediff --git a/server/services/pm2Standardizer.js b/server/services/pm2Standardizer.jsindex 0620c29881..5e637a6477 100644--- a/server/services/pm2Standardizer.js+++ b/server/services/pm2Standardizer.js@@ -167,6 +167,14 @@ async function executeCliAnalysis(provider, prompt, cwd) {return new Promise((resolve, reject) => {const args = [...(provider.args || []), prompt];let output = '';+ let settled = false;++ const settle = (fn, value) => {+ if (settled) return;+ settled = true;+ clearTimeout(timer);+ fn(value);+ };const child = spawn(provider.command, args, {cwd,@@ -184,18 +192,20 @@ async function executeCliAnalysis(provider, prompt, cwd) {child.on('close', (code) => {if (code === 0) {- resolve(output);+ settle(resolve, output);} else {- reject(new Error(`CLI exited with code ${code}`));+ settle(reject, new Error(`CLI exited with code ${code}`));}});- child.on('error', reject);+ child.on('error', (err) => settle(reject, err));- setTimeout(() => {+ const timeoutMs = provider.timeout || 180000;+ const timer = setTimeout(() => {+ console.log(`⏰ CLI analysis timed out after ${timeoutMs / 1000}s for: ${provider.command}`);child.kill();- reject(new Error('Standardization analysis timed out'));- }, provider.timeout || 120000);+ settle(reject, new Error(`Standardization analysis timed out after ${timeoutMs / 1000}s`));+ }, timeoutMs);});}@@ -208,15 +218,20 @@ async function executeApiAnalysis(provider, prompt) {headers['Authorization'] = `Bearer ${provider.apiKey}`;}+ const timeoutMs = provider.timeout || 180000;+ const controller = new AbortController();+ const timer = setTimeout(() => controller.abort(), timeoutMs);+const response = await fetch(`${provider.endpoint}/chat/completions`, {method: 'POST',headers,+ signal: controller.signal,body: JSON.stringify({model: provider.defaultModel,messages: [{ role: 'user', content: prompt }],temperature: 0.1})- });+ }).finally(() => clearTimeout(timer));if (!response.ok) {throw new Error(`API error: ${response.status}`);@@ -346,6 +361,9 @@ export async function analyzeApp(repoPath, providerId = null) {const prompt = buildStandardizationPrompt(context);// Execute analysis+ const startTime = Date.now();+ console.log(`🤖 Running ${provider.type} analysis via ${provider.name} (timeout: ${(provider.timeout || 180000) / 1000}s)`);+let response;if (provider.type === 'cli') {response = await executeCliAnalysis(provider, prompt, repoPath);@@ -355,6 +373,8 @@ export async function analyzeApp(repoPath, providerId = null) {return { success: false, error: 'Unknown provider type' };}+ console.log(`✅ Analysis response received in ${((Date.now() - startTime) / 1000).toFixed(1)}s`);+// Parse responseconst analysis = parseAnalysisResponse(response);