Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

the context.RequestAborted not reliable in HandleSseRequestAsync

オープン
#1,606 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
csharp
領域
api, backend

調査の方向性

HandleSseRequestAsync から開始し、RunSessionAsync がそれに関連付けられたキャンセル トークンをどのように使用しているかを追跡します。MCP Inspector で Connect をクリックしてからすぐに Ctrl+F4 を押して切断を再現し、その後、リクエストのキャンセル パスが実行されるかどうかを確認します。異常な切断によってセッションがキャンセルされ、RunSessionAsync が無期限に待機しないことを確認できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug needs confirmation P3

Describe the bug
the Request object will disposed when the connection was not normal disconnected, and the context.RequestAborted has two situations.
1.the context RequestAboated will disposed ,but will not raise registe event notify it was cancelled;because it just disposed.
2.the request will disposed, but the ReuqestAborted not changed,it stay not cancelled state.

the HandleSseRequestAsync method use RequestAborted to created a token source, when the request was disposed this token source will always be not cancelled, because it will not raise Registe event or RequestAborted will always not be cancelled, then the await RunSessionAsync will forever wait for next request.

using CancellationTokenSource sseCts = CancellationTokenSource.CreateLinkedTokenSource(context.RequestAborted, <hostApplicationLifetime>P.ApplicationStopping);

To Reproduce
Steps to reproduce the behavior:
just use mcp inspector ,click the "connect" button ,then quickly use ctrl+F4 to close the webpage,
or use RunSessionHandler to debug then wait it timeout.

Expected behavior
the cancellationToken must to become canceled, even the request was not normal disconnected.

Logs

Additional context
i have not better idea for this, maybe can use context.Reponse.OnCompleted(()=>sseCts.Cancel()) to fix the problem.

主要言語
C#
スター
4.5k
フォーク
814
平均マージ
9日 19時間
マージ済み PR(30日)
4

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/csharp-sdk のほかの issue

modelcontextprotocol/csharp-sdk の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。