For the complete documentation index, see llms.txt. This page is also available as Markdown.

Manage flow

The Manage Flow action node manages a Flow run that was started from an app with Run Flow. It stops the run, together with every Flow the run started. It is only available in apps.

Usage

This action node is useful in the following cases:

  • When a user should be able to cancel a long-running Flow, for example with a Stop button next to a report that takes minutes to generate.

  • When a Flow started with Run asynchronously should be stopped before it reaches its timeout.

Stop a Flow run

To stop a Flow run, the run needs an ID that another action can use while the run is still going:

  1. In the Run Flow action node that starts the Flow, bind Run ID to a String property, for example an app variable. The ID is stored before the Flow starts.

  2. In the action that should stop the run, for example the On Click action of a Stop button, add a Manage Flow action node.

  3. Set Operation to Stop and bind Run ID to the same property.

  4. Optionally, bind Result to a String property to find out what happened.

A run that was started without Run ID can't be stopped.

Good to know

Only the user who started a run can stop it. Anonymous users can't stop runs.

What happens to the run

When the stop reaches the run, the run ends at its next cancellation point:

  • A running Web Request, Streaming Web Request or Sleep action node is cancelled. So is the model call of a running Agent action node.

  • Any other action node, including data operations that write data, finishes first. The run then stops before the next action node.

Nothing the run has already done is rolled back.

The stop also reaches every Flow the run started, including Flows started with Run asynchronously. A stop that arrives after the last action node leaves the run completed, but still ends its asynchronous Flows.

The Run Flow action node that started the run fails with error 17036 (FlowRunStoppedError). To handle it in the calling action, add a Catch Exception node with 17036 in Appfarm Error Codes.

Result

Result stores one of the following values. They are results, not errors, so the action node doesn't fail when the run had already ended.

Value
Description

stopped

The stop reached the run. The run ends at its next cancellation point, and if it was just ending, it may have completed.

not_running

The run had already ended.

lost

The run can't be stopped. The server running it is gone, or the run was started without being registered.

Errors

The action node fails, without sending a stop, when Run ID is empty. Make sure Manage Flow runs after Run Flow has started.

The action node also fails with error 14404 when no run with that ID was started by the current user.

Properties

Property
Description

Operation

The operation to run on the Flow run. Stop stops the run and every Flow it started. A data write in progress finishes first.

Run ID

Required. The ID that Run Flow stored for the run, from a String property. You can stop only runs that you started.

Result

Optionally bind a String property to store the outcome: stopped, not_running or lost. See Result.

Was this helpful?