Skip to content

[CI] Flaky: MessageHandlerTest.AcceptSslCertificatesServicePointManager β€” httpbin.org premature response terminationΒ #25873

Closed

Description

@rolfbjarne

Flaky Test Report (automated)

Test: MonoTests.System.Net.Http.MessageHandlerTest.AcceptSslCertificatesServicePointManager(System.Net.Http.HttpClientHandler)
Platform: macOS (Debug, static registrar)
Category: Flaky (external network dependency)
Period: June 29–30, 2026

Occurrence Summary

PR Build Configuration Bot Attempt Direct Link
#25858 14517509 monotouch-test/macOS/Debug (static registrar) AcesShared 90 1 Run tests
#25858 14517509 monotouch-test/macOS/Debug (static registrar) AcesShared 8 2 Run tests (attempt 2)

Total: Failed consistently on both attempts (different bots), confirming it's not bot-specific.

Error Details

MonoTests.System.Net.Http.MessageHandlerTest.AcceptSslCertificatesServicePointManager(System.Net.Http.HttpClientHandler):
  Assert.That(ex, Is.Null)
  Expected: null
  But was: <System.Net.Http.HttpRequestException: Error while copying content to a stream.
    ---> System.Net.Http.HttpIOException: The response ended prematurely. (ResponseEnded)
    at System.Net.Http.HttpConnection.FillAsync(Boolean async)
    at System.Net.Http.HttpConnection.CopyToContentLengthAsync(...)
    at System.Net.Http.HttpConnection.ContentLengthReadStream.CompleteCopyToAsync(...)
    at System.Net.Http.HttpConnectionResponseContent.<SerializeToStreamAsync>g__Impl|6_0(...)
    at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(...)

Root Cause Analysis

The test makes HTTP requests to httpbin.org (an external service) using HttpClientHandler:

  • Calls httpbin.org/redirect/3 (follows 3 redirects)
  • The external server drops the TCP connection mid-response
  • HttpIOException: The response ended prematurely (ResponseEnded) is thrown

Why it's not caught as inconclusive:

The test calls TestRuntime.IgnoreInCIIfBadNetwork(ex) (tests/common/TestRuntime.cs:1618), which handles:

  • HTTP status codes (502, 504, 503)
  • Network connection lost (SocketException)
  • DNS resolution failures
  • Timeouts

But it does NOT handle HttpIOException / "response ended prematurely". This is a gap β€” premature response termination is clearly a network issue that should mark the test Inconclusive in CI.

Suggested Fix

Add a check for HttpIOException in IgnoreInCIIfBadNetwork:

// In TestRuntime.cs, add to IgnoreInCIIfBadNetwork(Exception? ex):
IgnoreInCIIfResponseEndedPrematurely (ex);

// New helper:
public static void IgnoreInCIIfResponseEndedPrematurely (Exception ex)
{
    var httpIoEx = FindInner<System.Net.Http.HttpIOException> (ex);
    if (httpIoEx is null)
        return;
    if (!IsRunningOnCI)
        return;
    Assert.Inconclusive ($"Ignoring network issue in CI: {httpIoEx.Message}");
}

Related Issues

Classification

This failure is unrelated to PR #25858 (which improves macOS test runner diagnostic output). It's caused by the external dependency on httpbin.org, which intermittently drops TCP connections.


This issue was automatically generated by CI post-mortem analysis.

Activity

  1. added
    bugIf an issue is a bug or a pull request a bug fix
    ci-failureThe issue only affects CI
    ci-postmortemCI post-mortem analysis: flaky tests, infrastructure failures, shared regressions
    on Jun 30, 2026
  2. added this to the Future milestone on Jun 30, 2026
  3. added a commit that references this issue on Jul 1, 2026
    fbae9d8
  4. rolfbjarne commented on Jul 6, 2026

    @rolfbjarne
    MemberAuthor

    CI Post-Mortem Update (2026-06-30 β†’ 2026-07-06)

    This flaky test recurred after the fix (#25875) was merged to main on 2026-07-01:

    PR Build Date Branch Direct link
    #25837 14526796 2026-06-30 main logs
    #25906 14550183 2026-07-02 xcode27.0 logs
    #25907 14550254 2026-07-02 net11.0 logs

    All three occurrences were on monotouch_macos with the same premature-connection-close error (net_http_content_stream_copy_error β†’ net_http_invalid_response_prematurely).

    Not reopening, because none of these recurrences invalidate the fix:

    No post-fix recurrence was observed on a main-based build. This should resolve on the affected branches once main is merged forward into xcode27.0 and net11.0.


    Automated CI post-mortem analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIf an issue is a bug or a pull request a bug fixci-failureThe issue only affects CIci-postmortemCI post-mortem analysis: flaky tests, infrastructure failures, shared regressionscopilot

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions