Skip to content

InvalidOperationException while using AddExtendedHttpClientLogging #7649

Closed

Description

@viorelbuligadev

Description

Extended HTTP logging breaks stream reads in Debug mode (.NET, Microsoft.Extensions.Http.Diagnostics 9.1+)
When using AddExtendedHttpClientLogging with HttpClient.GetAsync, reading the response stream in Debug mode throws InvalidOperationException: The stream was already consumed. Release mode is unaffected. Reproduced on 9.1+; not present on 9.0. Fix: use SendAsync with HttpCompletionOption.ResponseHeadersRead instead of GetAsync.

more info here: https://viorelbuliga.com/blog/extended-http-logging-stream-consumed
repro steps: https://github.com/viorelbuligadev/StreamConsumedRepro

Reproduction Steps

https://github.com/viorelbuligadev/StreamConsumedRepro

Expected behavior

using AddExtendedHttpClientLogging() should not throw any exceptions

Actual behavior

using AddExtendedHttpClientLogging() throw exception, check the git repo

Regression?

Reproduced on Microsoft.Extensions.Http.Diagnostics 9.1+; not present on 9.0.

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

  1. added
    bugThis issue describes a behavior which is not expected - a bug.
    on Jul 21, 2026
  2. MihuBot commented on Jul 21, 2026

    @MihuBot

    I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):

  3. added a commit that references this issue on Aug 4, 2026
    5e92e76
  4. locked and limited conversation to collaborators on Sep 4, 2026
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

    bugThis issue describes a behavior which is not expected - a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions