Run multi-target commands in parallel (#26)
CI / Lint (eslint) (pull_request) Successful in 27s
CI / Test (jest) (pull_request) Successful in 19s
CI / Security (npm audit) (pull_request) Successful in 12s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m58s
CI / Integration (api) (pull_request) Successful in 2m49s
CI / UI (playwright) (pull_request) Successful in 2m15s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 2m6s

- Workflow execute steps send to all targets at once and wait for every
  result (Promise.all), so one slow or hung worker no longer holds up the
  rest; any failed target fails the step. parallel: false keeps the old
  one-at-a-time order, stopping at the first failure, for rolling changes.
  (Log appends are atomic in SQL, so concurrent targets can't lose
  entries.)
- Quick Command's multi-worker mode sends to every selected worker at once.
- Integration tests: 3 workers x 2 s finish in about 2 s; parallel: false
  takes 6 s or more; one failing target fails the step after all report.
- README: the parallel field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-23 13:07:26 -05:00
1 parent 06d6c72709
commit abb4b9326f
4 files changed
+63 -33

No files matched your search

+26 -23
View File
@@ -1263,13 +1263,17 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
return false;
}
// Execute command on each target worker and wait for results
const results = [];
let sentCount = 0;
// Per-step timeout override: step.timeout (seconds) overrides global default
const stepTimeoutMs = step.timeout
? Math.min(Math.max(parseInt(step.timeout, 10) * 1000, 5000), 600000)
: COMMAND_TIMEOUT_MS;
// Per-step retry: step.retries (default 0) with step.retryDelayMs (default 2000)
const maxRetries = Math.min(parseInt(step.retries || 0, 10), 5);
const retryDelayMs = Math.min(parseInt(step.retryDelayMs || 2000, 10), 30000);
for (const workerId of targetWorkerIds) {
// Runs the command on one worker (with retries): { sent, success }.
const runOnWorker = async (workerId) => {
const workerWs = workers.get(workerId);
if (!workerWs || workerWs.readyState !== WebSocket.OPEN) {
await addExecutionLog(executionId, {
step: stepNumber,
@@ -1277,13 +1281,10 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
worker_id: workerId,
timestamp: new Date().toISOString()
});
continue;
return { sent: false, success: false };
}
sentCount++;
// Send command to worker
let commandId = crypto.randomUUID();
await addExecutionLog(executionId, {
step: stepNumber,
action: 'command_sent',
@@ -1292,12 +1293,6 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
command_id: commandId,
timestamp: new Date().toISOString()
});
// Per-step timeout override: step.timeout (seconds) overrides global default
const stepTimeoutMs = step.timeout
? Math.min(Math.max(parseInt(step.timeout, 10) * 1000, 5000), 600000)
: COMMAND_TIMEOUT_MS;
sendCommandToWorker(workerWs, {
type: 'execute_command',
execution_id: executionId,
@@ -1307,10 +1302,6 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
timeout: stepTimeoutMs
});
// Per-step retry: step.retries (default 0) with step.retryDelayMs (default 2000)
const maxRetries = Math.min(parseInt(step.retries || 0, 10), 5);
const retryDelayMs = Math.min(parseInt(step.retryDelayMs || 2000, 10), 30000);
let result;
let attempt = 0;
while (true) {
@@ -1340,13 +1331,25 @@ async function executeCommandStep(executionId, step, stepNumber, params = {}) {
});
commandId = retryCommandId; // update for next waitForCommandResult call
}
results.push(result);
return { sent: true, success: !!result.success };
};
if (!result.success) {
// Command failed after all retries, workflow should stop
return false;
// All targets at once (#26), so one slow or hung worker doesn't hold up the
// rest. `parallel: false` keeps the old one-at-a-time order for rolling changes,
// stopping at the first failure.
let outcomes;
if (step.parallel === false) {
outcomes = [];
for (const workerId of targetWorkerIds) {
const o = await runOnWorker(workerId);
outcomes.push(o);
if (o.sent && !o.success) return false;
}
} else {
outcomes = await Promise.all(targetWorkerIds.map(runOnWorker));
if (outcomes.some(o => o.sent && !o.success)) return false;
}
const sentCount = outcomes.filter(o => o.sent).length;
// If every target worker was offline, treat as step failure
if (sentCount === 0) {