Skip to content

feat: Add Stop mode to Run button to be able to cancel runs (workflows with Manual Trigger only)#482

Open
eskp wants to merge 1 commit intostagingfrom
feature/stop-execution-fix
Open

feat: Add Stop mode to Run button to be able to cancel runs (workflows with Manual Trigger only)#482
eskp wants to merge 1 commit intostagingfrom
feature/stop-execution-fix

Conversation

@eskp
Copy link
Member

@eskp eskp commented Mar 4, 2026

Summary

  • After clicking Stop on a running workflow, the Workflow DevKit runtime continues executing steps and writing "success" logs because it has no abort mechanism -- this caused steps to flash green and node borders to stay colored instead of resetting
  • Server-side guards in workflow-logging.ts now bail out of all logging functions (logStepStartDb, logStepCompleteDb, updateCurrentStep, incrementCompletedSteps) when the execution is in a terminal state
  • Cancel endpoint marks any in-flight "running" step logs as "error" and the internal PATCH route no longer overwrites a cancelled execution
  • Client-side: Runs panel does one final log refresh when transitioning to terminal then stops polling; toolbar resets nodes to idle on cancel; instant Run row appearance via runsRefreshTriggerAtom (replaces 2s poll delay)

Scope

The Stop button currently only appears during manual test runs (triggered via the toolbar Run button). Schedule, Webhook, and Event-triggered executions run server-side and have no UI stop mechanism yet. The cancel API endpoint is trigger-agnostic and works for any execution ID -- a per-execution Stop button in the Runs panel would be needed to let users cancel non-manual runs.

Test plan

  • Create a workflow with a slow HTTP Request step (e.g. httpbin.org/delay/10)
  • Click Run, then click Stop while the step is executing
  • Verify the step shows a red X (error) in the Runs panel, not green check
  • Verify the action node border resets to idle (no stuck blue/red border)
  • Verify the Run row appears instantly after clicking Run (no 2s delay)
  • Refresh the page and confirm step logs persist correctly (red X stays)
  • Run pnpm check && pnpm type-check -- both pass clean

The Workflow DevKit runtime has no abort mechanism, so after
the cancel endpoint sets status to "cancelled" the runtime
continues executing steps and writing "success" logs to the
DB. This causes steps to flash green and node borders to
stick on their last color.

Add three layers of defense:

- Server-side guards in workflow-logging.ts: logStepStartDb,
  logStepCompleteDb, updateCurrentStep, and
  incrementCompletedSteps all bail out when the execution is
  in a terminal state (cancelled/success/error)

- Cancel endpoint cleanup: mark any in-flight "running" step
  logs as "error" and protect the internal PATCH route from
  overwriting a cancelled execution

- Client-side fixes: Runs panel does one final log refresh
  when an execution transitions to terminal then stops
  polling it; toolbar resets nodes to idle on cancel; new
  runsRefreshTriggerAtom gives instant Run row appearance
  after clicking Run instead of waiting for the 2s poll
@eskp eskp requested review from a team, OleksandrUA, joelorzet and suisuss and removed request for a team March 4, 2026 03:15
@eskp eskp changed the title fix: prevent stale step logs and stuck node borders after stop execution fix: Change Run button mode to Stop in Workflows with Manual Trigger to be able to cancel runs Mar 4, 2026
@eskp eskp changed the title fix: Change Run button mode to Stop in Workflows with Manual Trigger to be able to cancel runs fix: Add Stop mode to Run button in Workflows with Manual Trigger to be able to cancel runs Mar 4, 2026
@eskp eskp changed the title fix: Add Stop mode to Run button in Workflows with Manual Trigger to be able to cancel runs fix: Add Stop mode to Run button to be able to cancel runs (workflows with Manual Trigger only) Mar 4, 2026
@eskp eskp changed the title fix: Add Stop mode to Run button to be able to cancel runs (workflows with Manual Trigger only) feat: Add Stop mode to Run button to be able to cancel runs (workflows with Manual Trigger only) Mar 4, 2026
await db
.update(workflowExecutionLogs)
.set({
status: "error",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a cancelled status. Would be good to use it instead of error

Copy link

@joelorzet joelorzet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment about status to keep consistency. Lgtm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants