Skip to content

Self-improving AI Employees for everyone

fix(triggers): preserve waiting status of non-firing triggers across runs

trohitg73d9f345e9cc
diff --git a/server/main.py b/server/main.py
index 4d8efe20..53c01be5 100644
--- a/server/main.py
+++ b/server/main.py
@@ -237,7 +237,16 @@ async def lifespan(app: FastAPI):
while True:
attempt += 1
client = await temporal_client_wrapper.connect(retries=1, delay=0)
- if client is not None:
+ if client is None:
+ # Surface every failed attempt to stdout so users can see
+ # the retry loop is still alive when "Temporal is up" but
+ # the Python client can't connect (server-up != client-up).
+ _startup_log(
+ f"[Temporal] Connect attempt {attempt} failed for "
+ f"{settings.temporal_server_address} (ns={settings.temporal_namespace}); "
+ "retrying in 3s"
+ )
+ else:
try:
temporal_executor = TemporalExecutor(
client=client,
@@ -261,6 +270,9 @@ async def lifespan(app: FastAPI):
)
return
except Exception as exc:
+ _startup_log(
+ f"[Temporal] Executor/worker setup failed (attempt {attempt}): {exc}; will retry"
+ )
logger.error(
"Temporal executor/worker setup failed; will retry",
error=str(exc),
diff --git a/server/routers/websocket.py b/server/routers/websocket.py
index 4cd8fe98..1febf261 100644
--- a/server/routers/websocket.py
+++ b/server/routers/websocket.py
@@ -480,7 +480,12 @@ async def handle_cancel_execution(data: Dict[str, Any], websocket: WebSocket) ->
async with broadcaster._workflow_active_lock:
broadcaster._workflow_active_runs.pop(workflow_id, None)
await broadcaster.update_workflow_status(executing=False, workflow_id=workflow_id)
- cleared = await broadcaster._clear_stuck_node_statuses(workflow_id)
+ # Explicit user cancel -- include `waiting` so the user sees every
+ # indicator go quiet. (Default sweep on run-end skips `waiting` to
+ # protect deployment trigger listeners.)
+ cleared = await broadcaster._clear_stuck_node_statuses(
+ workflow_id, include_waiting=True,
+ )
return {
"node_id": node_id,
diff --git a/server/services/status_broadcaster.py b/server/services/status_broadcaster.py
index 3972e20a..d150e60c 100644
--- a/server/services/status_broadcaster.py
+++ b/server/services/status_broadcaster.py
@@ -675,8 +675,16 @@ class StatusBroadcaster:
Returns True if this transition broadcast `executing=False` (i.e.
the counter went 1->0). When the counter reaches zero and
`clear_stuck_nodes` is set, any node currently marked
- `executing`/`waiting` for this workflow is reset to `idle` --
- protects the UI from glow leaks on crash paths.
+ `executing` for this workflow is reset to `idle` -- protects the
+ UI from glow leaks on crash paths.
+
+ Crucially does NOT clear `waiting` nodes -- in deployed workflows
+ with multiple triggers, every non-firing trigger sits in
+ `waiting` for the lifetime of the deployment (its collector loop
+ is still registered with event_waiter). Sweeping `waiting` on
+ every run completion would visually de-indicate those listeners
+ even though they're still alive. Explicit user cancels go through
+ `_clear_stuck_node_statuses(include_waiting=True)` instead.
"""
if not workflow_id:
return False
@@ -693,15 +701,33 @@ class StatusBroadcaster:
executing=False, workflow_id=workflow_id,
)
if clear_stuck_nodes:
+ # include_waiting=False (default) -- don't touch deployment
+ # trigger listeners, only sweep genuinely stuck `executing`
+ # nodes from a crashed run.
await self._clear_stuck_node_statuses(workflow_id)
return went_idle
- async def _clear_stuck_node_statuses(self, workflow_id: str) -> int:
- """Reset any nodes still marked executing/waiting for this workflow."""
+ async def _clear_stuck_node_statuses(
+ self,
+ workflow_id: str,
+ include_waiting: bool = False,
+ ) -> int:
+ """Reset stuck nodes for a workflow.
+
+ Default: only `executing` nodes are cleared. This is the right
+ behavior at run-completion boundaries because deployed trigger
+ nodes legitimately sit in `waiting` for the entire deployment
+ lifecycle and must not be wiped between runs.
+
+ Set `include_waiting=True` for explicit user cancels (toolbar
+ Stop, cancel_execution) where the user wants every indicator to
+ go quiet.
+ """
+ statuses = ("executing", "waiting") if include_waiting else ("executing",)
stuck = [
(nid, info) for nid, info in self._status["nodes"].items()
if info.get("workflow_id") == workflow_id
- and info.get("status") in ("executing", "waiting")
+ and info.get("status") in statuses
]
for node_id, _info in stuck:
try:
diff --git a/server/services/workflow.py b/server/services/workflow.py
index 15687c69..fcd6cd06 100644
--- a/server/services/workflow.py
+++ b/server/services/workflow.py
@@ -248,16 +248,41 @@ class WorkflowService:
if use_temporal is None:
use_temporal = self.settings.temporal_enabled
+ # Routing visibility — always logged at INFO so silent fallback to
+ # parallel/sequential is diagnosable without grepping warnings.
+ # If `chosen_path` is anything other than "temporal" while Temporal
+ # is enabled, that's the bug.
+ executor_wired = self._temporal_executor is not None
+ if use_temporal and executor_wired:
+ chosen = "temporal"
+ elif use_parallel and self.settings.redis_enabled:
+ chosen = "parallel"
+ else:
+ chosen = "sequential"
+ logger.info(
+ "[execute_workflow] routing decision: %s "
+ "(temporal_enabled=%s, executor_wired=%s, parallel=%s, redis=%s)",
+ chosen, use_temporal, executor_wired,
+ use_parallel, self.settings.redis_enabled,
+ extra={"workflow_id": workflow_id},
+ )
+
# Use Temporal if enabled and executor is configured
if use_temporal and self._temporal_executor is not None:
return await self._execute_temporal(nodes, edges, session_id, status_callback, start_time, workflow_id)
- # Log warning if Temporal was requested but not available
+ # Loud error if Temporal was requested but the executor never finished
+ # wiring. Previously a WARNING; bumped to ERROR because a silent
+ # fallthrough during a deployed-trigger run looks identical to a
+ # successful Temporal run from the user's perspective.
if use_temporal and self._temporal_executor is None:
- logger.warning(
+ logger.error(
"Temporal execution requested but executor not configured. "
- "Falling back to parallel/sequential execution. "
- "Check TEMPORAL_ENABLED and Temporal server connection."
+ "Falling back to %s execution. Check 'Temporal Worker started' "
+ "appeared in startup logs and that the Python client successfully "
+ "connected (server-up != client-connected).",
+ chosen,
+ extra={"workflow_id": workflow_id},
)
# Use parallel executor if enabled and Redis available