mirror of
https://mirror.skon.top/github.com/langgenius/dify.git
synced 2026-04-30 09:40:32 +08:00
improve workflow stop event handling
This commit is contained in:
@@ -410,7 +410,7 @@ class WorkflowBasedAppRunner:
|
||||
elif isinstance(event, GraphRunFailedEvent):
|
||||
self._publish_event(QueueWorkflowFailedEvent(error=event.error, exceptions_count=event.exceptions_count))
|
||||
elif isinstance(event, GraphRunAbortedEvent):
|
||||
self._publish_event(QueueWorkflowFailedEvent(error=event.reason or "Unknown error", exceptions_count=0))
|
||||
self._publish_event(QueueWorkflowPartialSuccessEvent(outputs={}, exceptions_count=0))
|
||||
elif isinstance(event, GraphRunPausedEvent):
|
||||
runtime_state = workflow_entry.graph_engine.graph_runtime_state
|
||||
paused_nodes = runtime_state.get_paused_nodes()
|
||||
|
||||
@@ -37,10 +37,13 @@ class AppTaskService:
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
# Legacy mechanism: Set stop flag in Redis
|
||||
AppQueueManager.set_stop_flag(task_id, invoke_from, user_id)
|
||||
|
||||
# New mechanism: Send stop command via GraphEngine for workflow-based apps
|
||||
# This ensures proper workflow status recording in the persistence layer
|
||||
if app_mode in (AppMode.ADVANCED_CHAT, AppMode.WORKFLOW):
|
||||
# Let the event handler process the Graphon abort event instead of
|
||||
# stopping the queue listener immediately. Otherwise, events may be
|
||||
# lost and the workflow run can remain stuck in the running state.
|
||||
GraphEngineManager(redis_client).send_stop_command(task_id)
|
||||
else:
|
||||
# Legacy mechanism: Set stop flag in Redis
|
||||
AppQueueManager.set_stop_flag(task_id, invoke_from, user_id)
|
||||
|
||||
Reference in New Issue
Block a user