When Chatflow Stop Fails: Why LLM Nodes Stay Loading After Cancel

    This article traces a Chatflow “stop generation” bug in visual LLM workflow platforms: after users cancel a run, LLM nodes can remain stuck in a loading state. It covers how stop spans frontend, streaming, the execution engine, and state storage; likely causes such as cancel signals that never reach node tasks, UI/backend desync, and missing terminal states; and engineering practices for cancel tokens, state-machine convergence, optimistic UI reset, and observability.

    When Chatflow Stop Fails: Why LLM Nodes Stay Loading After Cancel

    Background: “Stop” in visual workflows is not a simple button

    As LLM applications move into production, many teams assemble conversational systems on visual workflow platforms (often called Chatflow or Workflow). Users drag prompt templates, LLM calls, knowledge retrieval (RAG), and branches into an execution graph; a runtime engine schedules nodes in topological order.

    These products usually expose a Stop control so users can abort generation when output is wrong, too long, or no longer needed. That control looks like a UI action, but it crosses several layers:

    • Frontend: halt streaming render and reset node status from “running.”
    • Transport: close or abort the streaming connection (for example, a server-push event stream).
    • Execution engine: send a cancel signal to in-flight node tasks and reclaim resources.
    • State store: persist node status as canceled, not still running—whether in memory or logs.

    If any hop drops the signal, fails to write status, or swallows an error, a typical failure appears: the user clicked Stop, but the LLM node keeps spinning in Loading.

    What the bug looks like

    Community reports on an open-source LLM orchestration platform (public tracker issue #36088, still in progress) describe this: during a Chatflow run, Stop does not reset the LLM node on the frontend; it stays loading, so Stop feels broken.

    In the same release window, a related defect (#36055) was closed as fixed. That pattern suggests:

    1. The stop path has multiple weak points, not a single bug; similar issues can appear on different trigger paths.
    2. The team was patching these issues in a cluster, pointing to a shared regression in that version.
    3. Root causes are likely concurrent state and cancel propagation on event streams, so fixes usually need frontend and backend changes together.

    Why nodes get stuck in Loading

    From a typical streaming orchestration stack, several mechanisms can explain the hang.

    1. Cancel never reaches the node execution context

    Engines often run nodes as async tasks. Stop may be consumed only at the application layer (for example, ending the user-facing stream) and never forwarded to the LLM call still running. Then:

    • the LLM stream continues in the background;
    • the node state machine never sees a terminate event, so it never moves to completed/canceled;
    • the frontend’s event stream is gone and no status update arrives, so the last “running” render remains.

    2. Frontend state and backend events diverge

    Node status on the client is often driven by the event stream:

    1. // Node status typically follows the event stream
    2. ws.onmessage = (event) => {
    3. const msg = JSON.parse(event.data);
    4. updateNodeStatus(msg.nodeId, msg.status);
    5. };
    6. // Closing the socket without resetting nodes leaves UI in Loading
    7. stopButton.onclick = () => ws.close();

    If Stop only closes the connection and never marks running nodes canceled, Loading persists. A more robust pattern:

    1. stopButton.onclick = async () => {
    2. await requestStop(workflowRunId); // ask the backend to cancel
    3. ws.close(); // drop the event stream
    4. markRunningNodesAs(workflowRunId, 'canceled'); // client-side fallback
    5. };

    3. Exception paths never converge on a terminal state

    A node task usually goes pending → running → succeeded / failed / canceled. Many implementations write status only on success and failure, and skip cancel, timeout, and disconnect—so the state machine has no exit.

    If the LLM HTTP client lacks a read timeout or does not abort the underlying connection on cancel, the request can hang and widen the inconsistency window.

    Repair patterns and engineering practice

    A robust Stop path, independent of a specific product, typically includes the following.

    1. End-to-end cancel propagation

    • Use a runtime cancel token (a CancellationToken-style primitive) from the user Stop down the call chain.
    • Model calls and outbound HTTP should be abortable so work does not keep running after the UI has stopped.

    2. A state machine with a single set of terminals

    • Define terminals per node: succeeded, failed, canceled, timeout.
    • Use a timeout fallback so a node cannot stay Loading forever.
    • Catch all exit paths (try/finally or framework cleanup hooks) so status is always written.

    3. Optimistic reset plus event reconciliation on the client

    • On Stop, immediately mark running nodes canceled for instant feedback.
    • Reconcile when the server confirms.
    • After abnormal disconnects (network blips, restarts), query run status on reconnect and self-heal.

    4. Observability so hangs are diagnosable

    • Trace each run: when Stop was requested, when the engine received it, which nodes were canceled, and when they actually stopped.
    • Alert on cancel latency and “zombie” running nodes.

    Implications for platform users

    If you build on such platforms:

    1. Check whether tokens are still billed after Stop. A node left “running” may mean the backend request never died.
    2. Add application-level timeouts at the ingress so unbounded generation is cut off.
    3. Keep run logs for reproduction—run IDs and a timeline of actions help maintainers.
    4. Watch patch releases. In the example above, related defects were fixed in a short window; upgrading often resolves the issue.

    Closing

    Stop generation is easy to underestimate in streaming AI apps. It is not a button; it is cancel delivery and state consistency across UI, transport, and engine. Treat cancel and error paths as first-class, with the same design and tests as the happy path, so users get a clean, reliable abort when generation feels out of control.