fix: add mcp clearInterval#332
Conversation
WalkthroughThe change updates the cleanup logic in the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant MCPControllerRegister
participant SSETransport
Client->>MCPControllerRegister: Establish SSE connection
MCPControllerRegister->>SSETransport: Start keepalive interval
Note right of MCPControllerRegister: Store intervalId in sseConnections
SSETransport-->>MCPControllerRegister: onclose event
MCPControllerRegister->>MCPControllerRegister: Retrieve connection by sessionId
MCPControllerRegister->>MCPControllerRegister: Clear interval by intervalId
MCPControllerRegister->>MCPControllerRegister: Delete connection from sseConnections
Possibly related PRs
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
plugin/controller/lib/impl/mcp/MCPControllerRegister.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-eggache". (The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
plugin/controller/lib/impl/mcp/MCPControllerRegister.ts (1)
386-390: Good catch – interval now cleared, but consider centralising cleanup logicThe added block correctly clears the heartbeat interval and removes the entry from
sseConnections, preventing a potential timer leak.
However, very similar cleanup logic also lives inside the keep-alivesetIntervalcallback (lines 352-359). Having two places that both callclearInterval/deletemakes the code harder to reason about and increases the chance of them drifting apart.A small helper such as
private cleanupSSEConnection(id: string)would encapsulate the twoclearInterval + deleteoperations and let both the interval callback andtransport.onclosecall the same routine.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
plugin/controller/lib/impl/mcp/MCPControllerRegister.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: Runner-ubuntu (20)
- GitHub Check: Runner-macos (16)
- GitHub Check: Runner-ubuntu (22)
- GitHub Check: Runner-ubuntu (18)
- GitHub Check: Runner-macos (20)
- GitHub Check: Runner-macos (18)
- GitHub Check: Runner-ubuntu (16)
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (typescript)
Checklist
npm testpassesAffected core subsystem(s)
Description of change
Summary by CodeRabbit