fix(automations): include nodeId in SEND_DM payloads and keep single execution + ordered dispatch for multi-node turns
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- postgresql, typescript
- Área
- backend, distributed-systems
Línea de trabajo
Read apps/api/src/instagram/services/instagram-automation-runner.service.ts alongside apps/workers/src/workers/message-worker.ts, focusing on resumeWaitingExecution, triggerMatchingAutomations, and processSendMessageJob. Trace how multi-node turns create execution rows and schedule jobs, then check the existing worker handling of nodeId and isTerminalStep. Done means one execution per trigger, correct node IDs, ordered sends, and unchanged single-node and AI agent flows.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem Description
In apps/api/src/instagram/services/instagram-automation-runner.service.ts:
-
Missing
nodeIdinSEND_DMjob payloads:
NeitherresumeWaitingExecution(lines 486-498) nortriggerMatchingAutomations(lines 867-879) passesnodeId: actionNode.nodeIdinbackgroundJob.payload.
As a result,processSendMessageJob(apps/workers/src/workers/message-worker.ts, lines 293 & 313) logsExecutionStep.nodeIdas the generic fallback'ACTION_SEND_DM'instead of the actual canvas node ID, and falls back tocurrentExec.currentNodeIdfor downstream node checks. -
Duplicate / overwritten execution state & out-of-order risk when
waitForReplyAfterSend === false:
WhenDM 1haswaitForReplyAfterSend: falseand chains intoDM 2,resolveExecutableActionNodesreturns[DM 1, DM 2]in the same turn:triggerMatchingAutomations(lines 835-884) creates a separateAutomationExecutionrow for each node in the loop. BecauseDM 1hasnextNodeIds,message-worker.ts(line 315) seeshasNextNodes === trueand leaves Execution #1 stuck inPENDINGinstead ofCOMPLETED.resumeWaitingExecution(lines 467-475) overwritescurrentNodeIdon the samewaitingExecution.idin a loop before the worker runs.- Both jobs are queued with
runAfter = new Date()when delays are0, so across multiple worker replicasDM 2can be picked up beforeDM 1.
(Note: Normal single-node-per-reply flows with waitForReplyAfterSend: true are unaffected.)
Expected Behavior
- Every
SEND_DMBackgroundJobpayload includesnodeId: actionNode.nodeIdsoExecutionSteprecords the exact node ID. - Each automation trigger creates one
AutomationExecution(not one per node in a non-waiting chain), andWAITING/COMPLETEDstate is driven cleanly by the final node in that turn (isTerminalStep). - Sequential nodes queued in the same turn (
waitForReplyAfterSend: false) preserve send order (DM 1beforeDM 2) via cumulativerunAftertimestamps. - Single-node (
waitForReplyAfterSend: true) andACTION_AI_AGENTflows continue to behave identically with zero regressions.
Where to Look
apps/api/src/instagram/services/instagram-automation-runner.service.ts(resumeWaitingExecutionL404-508,triggerMatchingAutomationsL770-889)apps/workers/src/workers/message-worker.ts(processSendMessageJobL288-334 — already readsjob.data.nodeIdandjob.data.isTerminalStep)
Solution / Implementation Guide (Safe, Minimal Changes)
-
Pass
nodeIdin both payloads:- Add
nodeId: actionNode.nodeIdtobackgroundJob.payloadin bothresumeWaitingExecutionandtriggerMatchingAutomations.
- Add
-
Keep one
AutomationExecutionper trigger & preserveDM 1 -> DM 2order:- In
triggerMatchingAutomations, create oneAutomationExecutionper trigger (instead of creating a new row on every iteration ofactionNodesToExecute), updatingcurrentNodeIdandstatus(WAITINGvsPENDING) based on the final node in the turn. - Pass
isTerminalStep: isLastNodeInTurn && !shouldWaitinbackgroundJob.payload(whichmessage-worker.tslines 316-319 already support) soDM 1doesn't prematurely complete a waiting execution and single-node turns behave identically. - Track a cumulative
nextRunAfterMsacross nodes queued in the same turn (e.g.,Math.max(Date.now() + delaySec * 1000, prevRunAfterMs + 1000)for subsequent nodes) soDM 1is always eligible beforeDM 2.
- In
- Lenguaje dominante
- TypeScript
- Estrellas
- 2
- Forks
- 1
- Merge medio
- 6 min
- PR fusionados (30 d)
- 27
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de sumamakhan761/tryinstance
-
backend good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
sumamakhan761/tryinstance#65 ·
Los mantenedores suelen responder en 1 día
-
backend good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
sumamakhan761/tryinstance#64 ·
Los mantenedores suelen responder en 1 día
-
backend good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
sumamakhan761/tryinstance#63 ·
Los mantenedores suelen responder en 1 día
-
backend good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
sumamakhan761/tryinstance#62 ·
Los mantenedores suelen responder en 1 día
-
backend good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
sumamakhan761/tryinstance#60 ·
Los mantenedores suelen responder en 1 día
Todos los issues de sumamakhan761/tryinstance
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
makecindy/cindy#15342 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
kwitsch/claude-code-plugin-tooling#219 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
no-repo-link tool-submission
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100