[PR #12498] Fix the problem of Workflow terminates after parallel tasks execution, merge node not triggered #27655

Closed
opened 2026-02-21 20:41:56 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/12498

State: closed
Merged: Yes


Summary

Fix https://github.com/langgenius/dify/issues/12492

Description

When both if conditions are satisfied, the subsequent node is executed incompletely due to the following reasons:

  1. When init a Graph object, the _recursively_add_parallels method is used to create the mapping for parallel branches. When a node is found to have multiple outgoing edges, it is identified as the starting point of a parallel branch.
  2. In the GraphEngine's _run method, when multiple outgoing edges are encountered:
else:
    parallel_generator = self._run_parallel_branches(
        edge_mappings=edge_mappings,
        in_parallel_id=in_parallel_id,
        parallel_start_node_id=parallel_start_node_id,
        handle_exceptions=handle_exceptions,
    )

_run_parallel_branches creates a new thread for each branch to execute.

However:

  • When one branch completes execution, it places the result in the queue.
  • Once all branches have completed execution, the next node is executed.
  • If multiple branches satisfy the conditions and point to the same target node, only the first branch to complete will actually execute the target node.

Major Modifications:

  1. Collect all target nodes from the branches.
  2. For multiple branches pointing to the same target node, check which branches satisfy the conditions.
  3. Ensure that all branches meeting the conditions can trigger the execution of the target node.

This ensures that when multiple if condition branches are satisfied, their shared subsequent nodes are executed correctly.

Screenshots

Before After
image image

Checklist

Important

Please review the checklist below before submitting your pull request.

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/12498 **State:** closed **Merged:** Yes --- # Summary Fix https://github.com/langgenius/dify/issues/12492 # Description When both if conditions are satisfied, the subsequent node is executed incompletely due to the following reasons: 1. When init a Graph object, the _recursively_add_parallels method is used to create the mapping for parallel branches. When a node is found to have multiple outgoing edges, it is identified as the starting point of a parallel branch. 2. In the GraphEngine's _run method, when multiple outgoing edges are encountered: ``` else: parallel_generator = self._run_parallel_branches( edge_mappings=edge_mappings, in_parallel_id=in_parallel_id, parallel_start_node_id=parallel_start_node_id, handle_exceptions=handle_exceptions, ) ``` _run_parallel_branches creates a new thread for each branch to execute. However: * When one branch completes execution, it places the result in the queue. * Once all branches have completed execution, the next node is executed. * If multiple branches satisfy the conditions and point to the same target node, only the first branch to complete will actually execute the target node. ## Major Modifications: 1. Collect all target nodes from the branches. 2. For multiple branches pointing to the same target node, check which branches satisfy the conditions. 4. Ensure that all branches meeting the conditions can trigger the execution of the target node. This ensures that when multiple if condition branches are satisfied, their shared subsequent nodes are executed correctly. # Screenshots | Before | After | |--------|-------| | ![image](https://github.com/user-attachments/assets/f6a0a96f-fbd3-41b9-a815-1f6523d8eb15)| ![image](https://github.com/user-attachments/assets/0189a610-73d7-413b-80fe-037181873ae8) | # Checklist > [!IMPORTANT] > Please review the checklist below before submitting your pull request. - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:41:56 -05:00
yindo closed this issue 2026-02-21 20:41:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#27655