Skip to content

fix: connect error when sse with multiple clients#233

Merged
hustcc merged 3 commits into
mainfrom
fix-multiple-clients-when-sse
Nov 26, 2025
Merged

fix: connect error when sse with multiple clients#233
hustcc merged 3 commits into
mainfrom
fix-multiple-clients-when-sse

Conversation

@hustcc
Copy link
Copy Markdown
Member

@hustcc hustcc commented Nov 20, 2025

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @hustcc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical issue preventing multiple clients from simultaneously connecting via Server-Sent Events (SSE). The solution involves refactoring the server setup to ensure each client connection operates with its own isolated server instance, thereby eliminating resource contention. The changes are validated with new tests specifically designed to confirm stable multi-client SSE and streamable connections.

Highlights

  • Fix for Multiple SSE Clients: The core issue preventing multiple clients from simultaneously connecting via Server-Sent Events (SSE) has been resolved.
  • Per-Connection Server Instance: Each new SSE client connection now receives its own dedicated server instance, effectively preventing resource conflicts and enabling concurrent connections.
  • New Multi-Client Tests: Comprehensive new tests have been added to validate the stability and functionality of both SSE and streamable connections when multiple clients are active.
  • Increased Test Timeouts: Test execution timeouts have been extended to accommodate the new, potentially longer-running multi-client integration tests.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

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

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 effectively resolves the connection error for multiple SSE clients by instantiating a new server for each connection. The core logic change is sound and well-implemented in src/server.ts and src/services/sse.ts. I appreciate the addition of new tests in __tests__/server.spec.ts to cover multiple client scenarios for both SSE and streamable transports, which will help prevent future regressions. I have one suggestion to refactor the new tests to reduce code duplication and improve maintainability.

Comment thread __tests__/server.spec.ts
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 20, 2025

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.69%. Comparing base (0df6ba0) to head (028165f).

Files with missing lines Patch % Lines
src/services/sse.ts 0.00% 6 Missing ⚠️
src/server.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #233   +/-   ##
=======================================
  Coverage   79.69%   79.69%           
=======================================
  Files          41       41           
  Lines        1788     1788           
  Branches       31       31           
=======================================
  Hits         1425     1425           
  Misses        361      361           
  Partials        2        2           
Files with missing lines Coverage Δ
src/server.ts 0.00% <0.00%> (ø)
src/services/sse.ts 2.12% <0.00%> (-0.05%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hustcc hustcc merged commit 10330bc into main Nov 26, 2025
1 check passed
@hustcc hustcc deleted the fix-multiple-clients-when-sse branch November 26, 2025 06:57
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.

这个mcp两个client同时连接第2个会阻塞

2 participants