Skip to content

Commit 4443f79

Browse files
Copilothalter73
andcommitted
Adjust retry catch to OperationCanceledException
Co-authored-by: halter73 <54385+halter73@users.noreply.github.com>
1 parent 5360669 commit 4443f79

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

tests/ModelContextProtocol.AspNetCore.Tests/MapMcpTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public async Task LongRunningToolCall_DoesNotTimeout_WhenNoEventStreamStore()
254254
{
255255
// Create a custom HttpClient with a very short timeout (1 second)
256256
// The tool will take 2 seconds to complete
257-
using var shortTimeoutClient = new HttpClient(SocketsHttpHandler)
257+
using var shortTimeoutClient = new HttpClient(SocketsHttpHandler, disposeHandler: false)
258258
{
259259
BaseAddress = new Uri("http://localhost:5000/"),
260260
Timeout = TimeSpan.FromSeconds(1)
@@ -282,9 +282,7 @@ public async Task LongRunningToolCall_DoesNotTimeout_WhenNoEventStreamStore()
282282
Assert.Equal("Operation completed after 2000ms", content.Text);
283283
return;
284284
}
285-
catch (TaskCanceledException ex) when (
286-
attempt < 2 &&
287-
ex.ToString().Contains("HttpClient.Timeout", StringComparison.Ordinal))
285+
catch (OperationCanceledException) when (attempt < 2)
288286
{
289287
// Retry intermittent timeout-related failures on slow CI machines.
290288
}

0 commit comments

Comments
 (0)