From 18a6b642d19dfd59db6c506fcdd833366752c125 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Fri, 13 Mar 2026 13:48:35 -0400 Subject: [PATCH] Fix all-workers-offline silent success bug, noisy logging, UX polish server.js: - Fix bug: when all targeted workers disconnect before step runs, results[] was empty and results.every() returned true vacuously (silent false success). Now tracks sentCount and fails with 'no_workers' log if nothing was actually dispatched - Remove per-message console.log on every WebSocket message (high noise) - Only log a warning for failed commands (not every success) index.html: - loadSchedules() catch now shows error message in scheduleList (was silent) - abortExecution() shows server's error message from JSON body instead of generic string (e.g. "Execution is not running" instead of "Failed to abort execution") Co-Authored-By: Claude Sonnet 4.6 --- public/index.html | 4 +++- server.js | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/public/index.html b/public/index.html index 8ae36ba..61824b3 100644 --- a/public/index.html +++ b/public/index.html @@ -1376,6 +1376,7 @@ document.getElementById('scheduleList').innerHTML = html; } catch (error) { console.error('Error loading schedules:', error); + document.getElementById('scheduleList').innerHTML = '
⚠ Failed to load schedules
'; } } @@ -2369,7 +2370,8 @@ closeModal('viewExecutionModal'); refreshData(); } else { - alert('Failed to abort execution'); + const err = await response.json().catch(() => ({})); + alert(err.error || 'Failed to abort execution'); } } catch (error) { console.error('Error aborting execution:', error); diff --git a/server.js b/server.js index f4870ad..61f3abd 100644 --- a/server.js +++ b/server.js @@ -378,7 +378,6 @@ wss.on('connection', (ws) => { ws.on('message', async (data) => { try { const message = JSON.parse(data.toString()); - console.log('WebSocket message received:', message.type); if (message.type === 'command_result') { // Handle command result from worker @@ -427,7 +426,7 @@ wss.on('connection', (ws) => { is_automated: isAutomated, }); - console.log(`Command result received for execution ${execution_id}: ${success ? 'success' : 'failed'}`); + if (!success) console.warn(`[Worker] Command failed for execution ${execution_id} on worker ${worker_id}`); } if (message.type === 'workflow_result') { @@ -972,6 +971,7 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) { // Execute command on each target worker and wait for results const results = []; + let sentCount = 0; for (const workerId of targetWorkerIds) { const workerWs = workers.get(workerId); @@ -985,6 +985,7 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) { }); continue; } + sentCount++; // Send command to worker let commandId = crypto.randomUUID(); @@ -1052,8 +1053,18 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) { } } - // All commands succeeded - return results.every(r => r.success); + // If every target worker was offline, treat as step failure + if (sentCount === 0) { + await addExecutionLog(executionId, { + step: stepNumber, + action: 'no_workers', + message: 'All target workers were offline when step executed', + timestamp: new Date().toISOString() + }); + return false; + } + + return true; // all sent commands succeeded (failures return false above) } catch (error) { console.error(`[Workflow] Error executing command step:`, error);