Skip to content

【backup】pref: Change recursion to loop to avoid stack overflow#6486

Closed
wangliang181230 wants to merge 1 commit into
1Panel-dev:v2from
wangliang181230:PR/69-fix-avoidStackOverflow
Closed

【backup】pref: Change recursion to loop to avoid stack overflow#6486
wangliang181230 wants to merge 1 commit into
1Panel-dev:v2from
wangliang181230:PR/69-fix-avoidStackOverflow

Conversation

@wangliang181230

@wangliang181230 wangliang181230 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

Copilot AI review requested due to automatic review settings July 22, 2026 05:47
@wangliang181230 wangliang181230 changed the title pref: Avoid stack overflow pref: Change recursion to loop to avoid stack overflow Jul 22, 2026
@wangliang181230
wangliang181230 force-pushed the PR/69-fix-avoidStackOverflow branch from 6830988 to 773b1f8 Compare July 22, 2026 05:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a while True loop with continue to advance to the next node chunk.
  • Preserved the existing behavior for emitting the trailing \n\n stream 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.

Copilot AI review requested due to automatic review settings July 22, 2026 05:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

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:
@shaohuzhang1

Copy link
Copy Markdown
Contributor

v3 重构了工作流执行器

@wangliang181230 wangliang181230 changed the title pref: Change recursion to loop to avoid stack overflow 【backup】pref: Change recursion to loop to avoid stack overflow Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants