Skip to content

fix(core): stabilize message queue and thinking timeout - #974

Merged
dingyi222666 merged 1 commit into
v1-devfrom
fix/core-crash
Jul 13, 2026
Merged

dingyi222666 merged 1 commit into
v1-devfrom
fix/core-crash

Conversation

@dingyi222666

Copy link
Copy Markdown
Member

This pr stabilizes conversation message turn completion and thinking-message queue waiting to avoid race/crash paths.

New Features

  • None

Bug Fixes

  • Complete message turns in ChatChain finally blocks so queue cleanup always runs
  • Bind completeMessageTurn to the active turn to avoid completing the wrong queued turn
  • Replace thinking-message queue polling with a promise resolver for queue count
  • Report queue waiting length when acquiring conversation/platform locks

Other Changes

  • None

Validation

  • yarn lint-fix (0 errors, 2 existing warnings)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: fffef165-04c6-45f2-89cc-f9dd1f0c374d

📥 Commits

Reviewing files that changed from the base of the PR and between 9f6d7c5 and 98c772a.

📒 Files selected for processing (5)
  • packages/core/src/chains/chain.ts
  • packages/core/src/middlewares/chat/message_delay.ts
  • packages/core/src/middlewares/chat/thinking_message_send.ts
  • packages/core/src/middlewares/conversation/request_conversation.ts
  • packages/core/src/services/conversation_runtime.ts

Walkthrough

Changes

队列等待与轮次生命周期

Layer / File(s) Summary
队列等待计数传递
packages/core/src/middlewares/chat/thinking_message_send.ts, packages/core/src/middlewares/conversation/request_conversation.ts, packages/core/src/services/conversation_runtime.ts
运行时传递会话与模型队列长度,中间件通过 ThinkingTimeoutObject 的可解析队列接收计数。
消息轮次完成绑定
packages/core/src/middlewares/chat/message_delay.ts
completeTurn 校验指定队首轮次,完成当前轮次并清理或启动后续轮次。
链路异常清理保证
packages/core/src/chains/chain.ts
receiveMessage 与 runCommand 在 finally 中执行轮次完成和 recall 清理,并重置队列计数。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ConversationRuntime
  participant request_conversation
  participant thinking_message_send
  participant ChatChain
  participant message_delay
  ConversationRuntime->>request_conversation: 发送 llm-queue-waiting 计数
  request_conversation->>thinking_message_send: setQueueCount(count)
  thinking_message_send-->>thinking_message_send: await queueCount
  ChatChain->>message_delay: completeMessageTurn()
  message_delay->>message_delay: 校验并完成队首轮次
  ChatChain->>thinking_message_send: recallThinkingMessage()
Loading

Possibly related PRs

Poem

小兔挥耳守队列,
等待计数入梦乡。
轮次完成有凭证,
异常清理不慌张。
recall 归零月光亮,
代码蹦蹦向前忙。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题简洁且准确概括了稳定消息队列与思考超时的主要改动。
Description check ✅ Passed 描述与本次提交的队列清理、思考消息队列和锁等待优化一致,且未偏离变更内容。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/core-crash

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors message turn completion and queue count tracking by introducing a completeMessageTurn callback and a Promise-based queueCount mechanism. However, several critical issues were identified in the review. First, the event listeners in message_delay.ts may cause queue corruption by prematurely completing turns without checking the active turn; making the expected parameter required in completeTurn is recommended. Second, using a Promise to store queueCount prevents updating the count on subsequent events, so storing it in a mutable variable is preferred. Finally, potential errors in completeMessageTurn and the external onQueueWaiting callback should be wrapped in try-catch blocks to prevent blocking critical execution paths and cleanup processes.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/core/src/chains/chain.ts Resolved
Comment thread packages/core/src/chains/chain.ts Resolved
@dingyi222666
dingyi222666 merged commit 19d0e71 into v1-dev Jul 13, 2026
5 checks passed
@dingyi222666
dingyi222666 deleted the fix/core-crash branch July 13, 2026 15:34
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.

1 participant