fix(automations): include nodeId in SEND_DM payloads and keep single execution + ordered dispatch for multi-node turns
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- postgresql, typescript
- Ambito
- backend, distributed-systems
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 2
- Fork
- 1
- Merge medio
- 6m
- PR unite (30g)
- 27
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di sumamakhan761/tryinstance
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sumamakhan761/tryinstance#65 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
sumamakhan761/tryinstance#64 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
sumamakhan761/tryinstance#63 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sumamakhan761/tryinstance#62 ·
I maintainer di solito rispondono entro 1 giorno
-
backend good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sumamakhan761/tryinstance#60 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di sumamakhan761/tryinstance
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
makecindy/cindy#15342 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
kwitsch/claude-code-plugin-tooling#219 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
no-repo-link tool-submission
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 74/100
BraveOPotato/NoSignups#2618 ·
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100