【backup】pref: Change recursion to loop to avoid stack overflow#6486
Closed
wangliang181230 wants to merge 1 commit into
Closed
【backup】pref: Change recursion to loop to avoid stack overflow#6486wangliang181230 wants to merge 1 commit into
wangliang181230 wants to merge 1 commit into
Conversation
wangliang181230
force-pushed
the
PR/69-fix-avoidStackOverflow
branch
from
July 22, 2026 05:48
6830988 to
773b1f8
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the workflow streaming chunk manager to avoid potential stack overflows by replacing recursive re-entry in NodeChunkManage.pop() with an iterative loop, keeping behavior consistent while preventing deep recursion when consuming “end” node chunks.
Changes:
- Reworked
NodeChunkManage.pop()from recursion (return self.pop()) to awhile Trueloop withcontinueto advance to the next node chunk. - Preserved the existing behavior for emitting the trailing
\n\nstream chunk when an end node is reached and an answer has already been produced.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+70
to
+74
| try: | ||
| current_node_chunk = self.node_chunk_list.pop(0) | ||
| self.current_node_chunk = current_node_chunk | ||
| except IndexError as e: | ||
| pass |
| try: | ||
| chunk = self.current_node_chunk.chunk_list.pop(0) | ||
| return chunk | ||
| except IndexError as e: |
Contributor
|
v3 重构了工作流执行器 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it?
pref: Change recursion to loop to avoid stack overflow
优化:递归改为循环,避免栈溢出。
Summary of your change
Please indicate you've done the following: