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:
@@ -1376,6 +1376,7 @@
|
|||||||
document.getElementById('scheduleList').innerHTML = html;
|
document.getElementById('scheduleList').innerHTML = html;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading schedules:', 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');
|
closeModal('viewExecutionModal');
|
||||||
refreshData();
|
refreshData();
|
||||||
} else {
|
} else {
|
||||||
alert('Failed to abort execution');
|
const err = await response.json().catch(() => ({}));
|
||||||
|
alert(err.error || 'Failed to abort execution');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error aborting execution:', error);
|
console.error('Error aborting execution:', error);
|
||||||
|
|||||||
19
server.js
19
server.js
@@ -378,7 +378,6 @@ wss.on('connection', (ws) => {
|
|||||||
ws.on('message', async (data) => {
|
ws.on('message', async (data) => {
|
||||||
try {
|
try {
|
||||||
const message = JSON.parse(data.toString());
|
const message = JSON.parse(data.toString());
|
||||||
console.log('WebSocket message received:', message.type);
|
|
||||||
|
|
||||||
if (message.type === 'command_result') {
|
if (message.type === 'command_result') {
|
||||||
// Handle command result from worker
|
// Handle command result from worker
|
||||||
@@ -427,7 +426,7 @@ wss.on('connection', (ws) => {
|
|||||||
is_automated: isAutomated,
|
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') {
|
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
|
// Execute command on each target worker and wait for results
|
||||||
const results = [];
|
const results = [];
|
||||||
|
let sentCount = 0;
|
||||||
|
|
||||||
for (const workerId of targetWorkerIds) {
|
for (const workerId of targetWorkerIds) {
|
||||||
const workerWs = workers.get(workerId);
|
const workerWs = workers.get(workerId);
|
||||||
@@ -985,6 +985,7 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
|
|||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
sentCount++;
|
||||||
|
|
||||||
// Send command to worker
|
// Send command to worker
|
||||||
let commandId = crypto.randomUUID();
|
let commandId = crypto.randomUUID();
|
||||||
@@ -1052,8 +1053,18 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// All commands succeeded
|
// If every target worker was offline, treat as step failure
|
||||||
return results.every(r => r.success);
|
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) {
|
} catch (error) {
|
||||||
console.error(`[Workflow] Error executing command step:`, error);
|
console.error(`[Workflow] Error executing command step:`, error);
|
||||||
|
|||||||
Reference in New Issue
Block a user