Skip to content

fix(agent): avoid context timer during MCP shutdown - #1023

Merged
dingyi222666 merged 1 commit into
ChatLunaLab:v1-devfrom
Hoshino-Yumetsuki:v1-dev
Aug 21, 2026
Merged

dingyi222666 merged 1 commit into
ChatLunaLab:v1-devfrom
Hoshino-Yumetsuki:v1-dev

Conversation

@Hoshino-Yumetsuki

@Hoshino-Yumetsuki Hoshino-Yumetsuki commented Aug 16, 2026

Copy link
Copy Markdown
Member

Use a non-context Node timer for the MCP client close deadline so service disposal does not create a Cordis effect after the context becomes inactive.

Constraint: Preserve the five-second close bound without keeping Node alive

Rejected: Revert progressive MCP disclosure | broader unrelated behavior loss

Confidence: high

Scope-risk: narrow
Copilot AI lite review requested due to automatic review settings August 16, 2026 15:35
@coderabbitai

coderabbitai Bot commented Aug 16, 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 Plus

Run ID: fcf78839-9b39-4d7f-ac84-e9037a868bdf

📥 Commits

Reviewing files that changed from the base of the PR and between ca1177d and e70587a.

📒 Files selected for processing (1)
  • packages/extension-agent/src/service/mcp.ts

Included review availability: Your plan includes up to 2 reviews per rolling hour; 1 remains after this review.


Walkthrough

本次变更调整 MCP 客户端关闭流程。代码使用 node:timers/promiseswait 替代 Koishi 定时器 Promise,并设置 { ref: false }

Changes

MCP 客户端关闭

Layer / File(s) Summary
替换关闭超时等待
packages/extension-agent/src/service/mcp.ts
导入 wait_closeClient 使用 wait(5000, undefined, { ref: false }) 等待客户端关闭。

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to e7058

This narrowly changes the MCP shutdown timer behavior to preserve the close deadline without keeping the Node process alive; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: dingyi222666, lumia1998

Poem

兔子敲代码,
等待轻轻跑。
五秒不挂钩,
客户端安静关掉。
胡萝卜也笑了。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive 未提供 PR 描述,因此缺少对变更内容的直接说明。 请补充简短描述,说明 MCP 关闭流程改用非上下文 Node.js 计时器的目的。
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed 标题准确概括了 MCP 关闭流程改用非上下文定时器的主要变更,并说明了修复目的。
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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 adjusts the MCP client shutdown path in extension-agent to avoid relying on Koishi Context timers during teardown, addressing the startup/shutdown error reported in #1022.

Changes:

  • Replaces a ctx.setTimeout-based shutdown timeout with node:timers/promises setTimeout.
  • Uses an unref’ed timer ({ ref: false }) so the timeout mechanism won’t keep the Node.js event loop alive during shutdown.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dingyi222666
dingyi222666 merged commit 69732ed into ChatLunaLab:v1-dev Aug 21, 2026
5 checks passed
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