Skip to content

Reduce flakiness in long-running stateless HTTP tool timeout test#1300

Open
Copilot wants to merge 3 commits intomainfrom
copilot/improve-test-reliability
Open

Reduce flakiness in long-running stateless HTTP tool timeout test#1300
Copilot wants to merge 3 commits intomainfrom
copilot/improve-test-reliability

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

  • Review new PR comments and confirm actionable feedback
  • Inspect current implementation and recent commits for the affected test
  • Update retry logic to use OperationCanceledException as requested
  • Run targeted test for LongRunningToolCall_DoesNotTimeout_WhenNoEventStreamStore
  • Run build and full test suite to validate no regressions
  • Run automated code review and security scan
  • Reply on addressed comment threads with the commit hash

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: halter73 <54385+halter73@users.noreply.github.com>
@halter73 halter73 marked this pull request as ready for review February 17, 2026 21:22
Copy link
Contributor

@halter73 halter73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended to reduce test failures like the following:

  Failed ModelContextProtocol.AspNetCore.Tests.MapMcpStatelessTests.LongRunningToolCall_DoesNotTimeout_WhenNoEventStreamStore [1 s]
  Error Message:
   System.Threading.Tasks.TaskCanceledException : The request was canceled due to the configured HttpClient.Timeout of 1 seconds elapsing.

https://github.com/modelcontextprotocol/csharp-sdk/actions/runs/22092487205/job/63841819265?pr=1295

We could consider using a timeout of larger than 1 second to reduce the flakiness, but then we'd have to make the LongRunningToolCall longer too. I think this retry logic should reduce the flakiness enough while still keeping the test shortish, but I'm open to ideas for alternative ways to test this that are faster or more reliable.

Copilot AI changed the title [WIP] Update LongRunningToolCall test for reliability and performance Reduce flakiness in long-running stateless HTTP tool timeout test Feb 17, 2026
Copilot AI requested a review from halter73 February 17, 2026 21:28
}
catch (TaskCanceledException ex) when (
attempt < 2 &&
ex.ToString().Contains("HttpClient.Timeout", StringComparison.Ordinal))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part necessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Update this to retry for any OperationCanceledException.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 4443f79: the retry now catches any OperationCanceledException (bounded by attempt < 2), and I removed the timeout-string check.

Assert.Equal("Operation completed after 2000ms", content.Text);
return;
}
catch (TaskCanceledException ex) when (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be OperationCanceledException

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 4443f79: switched this to OperationCanceledException.

stephentoub
stephentoub previously approved these changes Feb 17, 2026
Co-authored-by: halter73 <54385+halter73@users.noreply.github.com>
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.

3 participants

Comments