Fix waitForCommandResult: match by position, not command_id

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 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 11:21:30 -05:00
parent bf9b14bc96
commit 937bddbe2f

View File

@@ -777,7 +777,12 @@ async function waitForCommandResult(executionId, commandId, timeout) {
if (execution.length > 0) { if (execution.length > 0) {
const logs = typeof execution[0].logs === 'string' ? JSON.parse(execution[0].logs) : execution[0].logs; 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) { if (resultLog) {
clearInterval(checkInterval); clearInterval(checkInterval);