fix(mcp-server): optimize session validation to prevent 2-second time#3106
Merged
hengyunabc merged 1 commit intoalibaba:masterfrom Dec 25, 2025
Merged
Conversation
…out delays Previously, session validation used pullResults() which would block for up to 2 seconds when no results were available, causing Cherry Studio and other clients to timeout. Changes: - Replace blocking pullResults() validation with time-based expiry check (25 min threshold) - Add lastAccessTime tracking to CommandSessionBinding for efficient validation
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.
问题描述
在使用 Cherry Studio 作为客户端连接
arthas-mcp-server时,出现了严重的延迟问题:ping请求)都会延迟约 2 秒notifications/cancelledwith reason "Request timed out"mcp-inspector中不会出现,仅在 Cherry Studio 中出现根本原因
通过日志分析发现,问题出在
ArthasCommandSessionManager.isSessionValid()方法中:commandExecutor.pullResults()来验证 session 是否有效pullResults()是一个长轮询设计,当没有结果时会等待最多 2 秒(ResultConsumerImpl.pollTimeLimit = 2000ms)ping等简单请求,由于没有新的命令结果,会触发完整的 2 秒等待