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

NewRelic Agent 10.19.1 breaks Swagger #2051

Closed
egg-r opened this issue Nov 9, 2023 · 2 comments · Fixed by #2059 or #2064
Closed

NewRelic Agent 10.19.1 breaks Swagger #2051

egg-r opened this issue Nov 9, 2023 · 2 comments · Fixed by #2059 or #2064
Labels
bug Something isn't working community To tag external issues and PRs

Comments

@egg-r
Copy link

egg-r commented Nov 9, 2023

Description

This week we restarted receiving reports of Swagger not being able to load by developers this week. We found that this issue is only occurring on environments which have NewRelic profiling enabled. Profiler enablement is controlled by Kubernetes environment variables in our setup. Disabling profiling via K8s environment variables allowed Swagger to work properly. Turn it back on and Swagger fails with the below console output. We then traced what changed down to the NewRelic latest agent updates, 10.19.1 . Previous docker images with agent version installations prior to version 10.19.x are working fine. With Swagger being broken, we're pretty worried now about other aspects of our application also having issues so we disabled profiling globally while this bug gets reviewed.

Expected Behavior

The NewRelic agent should not be breaking Swagger or other bits of code that rely on Kestrel.

Troubleshooting or NR Diag results

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.InvalidOperationException: Headers are read-only, response has already started.
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.ThrowHeadersReadOnlyException()
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.set_ContentLength(Nullable`1 value)
         at Microsoft.AspNetCore.Http.DefaultHttpResponse.set_ContentLength(Nullable`1 value)
         at NewRelic.Providers.Wrapper.AspNetCore6Plus.BrowserInjectingStreamWrapper.FlushAsync(CancellationToken cancellationToken)
         at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionBody.FlushAsync(CancellationToken cancellationToken)
         at System.IO.Pipelines.StreamPipeWriter.FlushAsyncInternal(Boolean writeToStream, ReadOnlyMemory`1 data, CancellationToken cancellationToken)
         at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.RespondWithIndexHtml(HttpResponse response)
         at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
         at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
warn: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[2]
      The response has already started, the error handler will not be executed.
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HMV0T1A0SJP9", Request id "0HMV0T1A0SJP9:00000002": An unhandled exception was thrown by the application.
      System.InvalidOperationException: Headers are read-only, response has already started.
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.ThrowHeadersReadOnlyException()
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.set_ContentLength(Nullable`1 value)
         at Microsoft.AspNetCore.Http.DefaultHttpResponse.set_ContentLength(Nullable`1 value)
         at NewRelic.Providers.Wrapper.AspNetCore6Plus.BrowserInjectingStreamWrapper.FlushAsync(CancellationToken cancellationToken)
         at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionBody.FlushAsync(CancellationToken cancellationToken)
         at System.IO.Pipelines.StreamPipeWriter.FlushAsyncInternal(Boolean writeToStream, ReadOnlyMemory`1 data, CancellationToken cancellationToken)
         at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.RespondWithIndexHtml(HttpResponse response)
         at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
         at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
         at Scorpion.Stretch.Web.EnableBuffering.InvokeAsync(HttpContext context)
         at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.InvokeCore(HttpContext context)
         at NewRelic.Providers.Wrapper.AspNetCore6Plus.WrapPipelineMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

Steps to Reproduce
Use the latest NR agent 10.19.1

Your Environment
Docker image mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim on AKS

Additional context

For Maintainers Only or Hero Triaging this bug
Suggested Priority (P1,P2,P3,P4,P5):
Suggested T-Shirt size (S, M, L, XL, Unknown):

@egg-r egg-r added the bug Something isn't working label Nov 9, 2023
@workato-integration
Copy link

@github-actions github-actions bot added the community To tag external issues and PRs label Nov 9, 2023
@tippmar-nr
Copy link
Member

@egg-r Thanks for your report. We're currently working on an updated release that will disable ASP.NET Core 6+ browser agent injection by default, which will alleviate the issues you're seeing. That release should be available within the next day or so.

We will be investigating the issue you reported and working to resolve them so that we can re-enable browser agent injection by default in a future release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community To tag external issues and PRs
Projects
None yet
2 participants