Skip to content

Fix Flaky HTTP/3 Test: POST_ClientCancellationUpload_RequestAbortRaised - #68111

Open
PreethikaSelvam wants to merge 3 commits into
dotnet:mainfrom
PreethikaSelvam:67518-test-update
Open

Fix Flaky HTTP/3 Test: POST_ClientCancellationUpload_RequestAbortRaised#68111
PreethikaSelvam wants to merge 3 commits into
dotnet:mainfrom
PreethikaSelvam:67518-test-update

Conversation

@PreethikaSelvam

@PreethikaSelvam PreethikaSelvam commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes intermittent failures in Http3RequestTests.POST_ClientCancellationUpload_RequestAbortRaised caused by timing-dependent behavior when reading the request body after client cancellation in HTTP/3.

Validation / Investigation

The failing test intermittently reported:
Assert.Throws() Failure: No exception was thrown Expected: typeof(System.IO.IOException)

To investigate the issue, the test was executed in a local stress run of 1000 iterations, during which the failure was successfully reproduced. Analysis of both local and CI failures confirmed that:

  • Client cancellation was successfully triggered.
  • The server observed the RequestAborted notification.
  • HTTP/3 stream reset (H3_REQUEST_CANCELLED) was received.
  • The request completed with HTTP 499.

The flakiness was caused by the final request body read after cancellation. Depending on timing, two valid outcomes were observed:

ReadAsync() throws:
IOException("The client reset the request stream.")

ReadAsync() completes successfully and returns:
0
indicating EOF.

The existing test only accepted the exception path, causing intermittent failures whenever EOF was observed instead.

Validation

  • Successfully reproduced the failure locally using a 1000-iteration stress run.
  • Confirmed that RequestAborted was raised in both passing and failing runs.
  • Confirmed that the HTTP/3 cancellation path remained unchanged.
  • Verified that the updated test handles both valid post-cancellation outcomes (IOException or EOF).
  • Test-only change with no product code modifications.

Changes

  • Replaced the strict Assert.ThrowsAsync() validation with logic that accepts both valid post-cancellation outcomes: an IOException when the stream reset is observed or a successful read returning 0 bytes (EOF).
  • Updated the final request-body read validation to handle timing-dependent HTTP/3 transport behavior instead of assuming cancellation always surfaces as an exception.
  • Changed TaskCompletionSource to TaskCompletionSource<Task> to correctly represent the return type of ReadAsync() and enable validation of the returned byte count.
  • Preserved existing cancellation verification by continuing to validate that the server observes the RequestAborted notification before evaluating the final read result.
  • Stabilized the test by removing reliance on a transport-specific timing assumption while maintaining validation of client cancellation behavior.

Fixes #67518 & #58802

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 30, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @PreethikaSelvam. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@PreethikaSelvam
PreethikaSelvam marked this pull request as ready for review July 30, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quarantine Http3RequestTests.POST_ClientCancellationUpload_RequestAbortRaised

1 participant