-
Notifications
You must be signed in to change notification settings - Fork 214
Description
Summary
The /api/channels/cancel endpoint exists and is correctly registered, but returns 404
when attempting to cancel workers that appear as "running" in the UI.
Root Cause
There is a data source mismatch between the workers list and the cancel API:
Workers list (/api/agents/workers) |
Cancel API (/api/channels/cancel) |
|
|---|---|---|
| Data source | SQLite DB (persisted) | In-memory channel_states (volatile) |
| After server restart | Workers remain "running" | Map is cleared |
channel_states is only populated when a new inbound message is received in the
current server session (main.rs:1618). On server restart, this map is empty.
Meanwhile, list_workers reads from the database, which still shows workers as
\"running\" because there is no cleanup of stale worker rows on startup.
As a result:
- Server restarts (for any reason)
- DB still shows worker as
\"running\"→ UI shows Cancel button channel_statesis empty →cancel_processreturns404 NOT_FOUND
Steps to Reproduce
- Start a long-running worker via a Telegram message
- Restart the server
- Open the Workers page — worker still shows as "running"
- Click Cancel →
POST /api/channels/cancelreturns 404
Suggested Fix
On server startup, mark all workers with status = "running" as interrupted/cancelled
in the DB, so the UI does not show a Cancel button for workers that can no longer be
cancelled via the in-memory API.
Alternatively, the cancel API could return a more descriptive error (e.g. 410 Gone or
a JSON error body) rather than a bare 404, to distinguish "channel not found in memory"
from "endpoint not found".
Environment
- Endpoint:
POST /api/channels/cancel - Reproducer payload:
{"channel_id":"telegram:373412422","process_type":"worker","process_id":"11bb8879-fde7-4005-8d52-30c77cdd1a93"}