From 937bddbe2fe9e95db8fe794b2805b4556cd633ac Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Wed, 4 Mar 2026 11:21:30 -0500 Subject: [PATCH] Fix waitForCommandResult: match by position, not command_id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Worker does not echo command_id back in command_result message. Previously this caused all workflow steps to time out after 120s. Now: find the command_sent entry for the commandId, then take the next command_result after it — safe since steps run sequentially. Co-Authored-By: Claude Sonnet 4.6 --- server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 13920f1..9d3a278 100644 --- a/server.js +++ b/server.js @@ -777,7 +777,12 @@ async function waitForCommandResult(executionId, commandId, timeout) { if (execution.length > 0) { const logs = typeof execution[0].logs === 'string' ? JSON.parse(execution[0].logs) : execution[0].logs; - const resultLog = logs.find(log => log.command_id === commandId && log.action === 'command_result'); + // Find the command_sent entry for this commandId, then look for the next command_result after it. + // (Worker doesn't echo command_id back, so we can't match by command_id directly.) + const sentIdx = logs.findIndex(l => l.command_id === commandId && l.action === 'command_sent'); + const resultLog = sentIdx >= 0 + ? logs.slice(sentIdx + 1).find(l => l.action === 'command_result') + : logs.find(l => l.command_id === commandId && l.action === 'command_result'); if (resultLog) { clearInterval(checkInterval);