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 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 13:48:35 -04:00
parent 8ff3700601
commit 18a6b642d1
2 changed files with 18 additions and 5 deletions

View File

@@ -1376,6 +1376,7 @@
document.getElementById('scheduleList').innerHTML = html;
} catch (error) {
console.error('Error loading schedules:', error);
document.getElementById('scheduleList').innerHTML = '<div class="empty" style="color:var(--terminal-red);">⚠ Failed to load schedules</div>';
}
}
@@ -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);

View File

@@ -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);