Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingMethodException: RecyclableMemoryStreamManager.GetStream() #4967

Closed
0xfeeddeadbeef opened this issue Feb 23, 2024 · 4 comments · Fixed by #4976
Closed

MissingMethodException: RecyclableMemoryStreamManager.GetStream() #4967

0xfeeddeadbeef opened this issue Feb 23, 2024 · 4 comments · Fixed by #4976
Assignees
Labels
area-telemetry bug This issue describes a behavior which is not expected - a bug.
Milestone

Comments

@0xfeeddeadbeef
Copy link

Description

When a project that is using Microsoft.Extensions.Http.Diagnostics has a direct dependency on version 3.0.0 of Microsoft.IO.RecyclableMemoryStream package and you try to use AddExtendedHttpClientLogging with body content logging enabled, it will fail with MissingMethodException: RecyclableMemoryStreamManager.GetStream().

Reproduction Steps

  1. Create a new ASP.NET Web API project
  2. Add <PackageReference Include="Microsoft.Extensions.Http.Diagnostics" Version="8.2.0" />
  3. Add <PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
  4. Add a HTTP client with body logging enabled: clientBuilder.AddExtendedHttpClientLogging(x => { x.LogBody = true; });
  5. Send a request using this HTTP client

Expected behavior

HTTP request and response bodies are logged without any errors.

Actual behavior

An error occurred while reading the response data to fill the logger context for request: {http.request.method} {server.address}/{url.path} <s:Microsoft.Extensions.Http.Logging.HttpClientLogger>
System.MissingMethodException: Method not found: 'System.IO.MemoryStream Microsoft.IO.RecyclableMemoryStreamManager.GetStream()'.
   at Microsoft.Extensions.Http.Logging.Internal.HttpResponseBodyReader.ReadFromStreamAsync(HttpResponseMessage response, Int32 readSizeLimit, RecyclableMemoryStreamManager streamManager, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Extensions.Http.Logging.Internal.HttpResponseBodyReader.ReadFromStreamAsync(HttpResponseMessage response, Int32 readSizeLimit, RecyclableMemoryStreamManager streamManager, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.Internal.HttpResponseBodyReader.ReadFromStreamWithTimeoutAsync(HttpResponseMessage response, TimeSpan readTimeout, Int32 readSizeLimit, RecyclableMemoryStreamManager streamManager, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.Internal.HttpRequestReader.ReadResponseAsync(LogRecord logRecord, HttpResponseMessage response, List`1 responseHeadersBuffer, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.HttpClientLogger.LogResponseAsync(Object context, HttpRequestMessage request, HttpResponseMessage response, Exception exception, TimeSpan elapsed, CancellationToken cancellationToken)

Regression?

No response

Known Workarounds

Use 2.x versions of Microsoft.IO.RecyclableMemoryStream package:

<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />

Configuration

No response

Other information

No response

@0xfeeddeadbeef 0xfeeddeadbeef added bug This issue describes a behavior which is not expected - a bug. untriaged labels Feb 23, 2024
@RussKie
Copy link
Member

RussKie commented Feb 23, 2024

@dotnet/dotnet-r9-telemetry could you please investigate?

@xakep139
Copy link
Contributor

Thanks for reporting this, @0xfeeddeadbeef
It seems that version 3.0.0 of Microsoft.IO.RecyclableMemoryStream package has a bunch of breaking changes: https://github.com/microsoft/Microsoft.IO.RecyclableMemoryStream/releases/tag/3.0.0, including GetStream() method overloads.
Even though we can update our dependencies to rely on version 3 instead of 2, this might break existing users who rely on version 2.x in their code.
@geeknoid @joperezr thoughts?

@geeknoid
Copy link
Member

I think we should take the leap and upgrade our dependency. It's the only way stuff will keep working in the long run, otherwise we'll fall behind forever.

@xakep139
Copy link
Contributor

xakep139 commented Mar 4, 2024

@0xfeeddeadbeef the changes will be released in version 8.3.0

@xakep139 xakep139 added this to the 8.3 milestone Mar 4, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-telemetry bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants