Stacks endpoint throws unhandled Error 500
AntonPalyok opened this issue · 4 comments
Description
I'm using dotnet-monitor tool version 8.0.2 (latest at the moment).
When I call /stack
endpoint, for example https://localhost:52323/stacks?pid=42824 - I receive Http Status Code 500 in browser.
In the console log of dotnet-monitor command I can see an Unhandled Exception
StackTrace of an error:
17:02:47 fail: Microsoft.AspNetCore.Server.Kestrel[13]
=> SpanId:20a10a8b85e5e0fa, TraceId:c364432c4a1397d7bbc5d8edae55305e, ParentId:0000000000000000 => ConnectionId:0HN41GATLTQSL => RequestPath:/stacks RequestId:0HN41GATLTQSL:00000003
Connection id "0HN41GATLTQSL", Request id "0HN41GATLTQSL:00000003": An unhandled exception was thrown by the application.
System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ConnectAsync(Socket socket)
at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP)
at Microsoft.Diagnostics.Monitoring.WebApi.ProfilerChannel.SendMessage(IEndpointInfo endpointInfo, IProfilerMessage message, CancellationToken token) in /_/src/Microsoft.Diagnostics.Monitoring.WebApi/ProfilerChannel.cs:line 41
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Diagnostics.Monitoring.WebApi.ProfilerChannel.SendMessage(IEndpointInfo endpointInfo, IProfilerMessage message, CancellationToken token)
at Microsoft.Diagnostics.Tools.Monitor.Stacks.StacksOperation.StacksOperationPipeline.StartAsync(CancellationToken token) in /_/src/Tools/dotnet-monitor/Stacks/StacksOperation.cs:line 85
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.ExecutionContextCallback(Object s)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext()
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(IAsyncStateMachineBox box, Boolean allowInlining)
at System.Threading.Tasks.Task.RunContinuations(Object continuationObject)
at System.Threading.Tasks.Task`1.TrySetResult(TResult result)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.SetExistingTaskResult(Task`1 task, TResult result)
at Microsoft.Diagnostics.Monitoring.EventPipe.EventSourcePipeline`1.StartAsync(CancellationToken token)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.ExecutionContextCallback(Object s)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext()
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(IAsyncStateMachineBox box, Boolean allowInlining)
at System.Threading.Tasks.Task.RunContinuations(Object continuationObject)
at System.Threading.Tasks.Task`1.TrySetResult(TResult result)
at System.Threading.Tasks.UnwrapPromise`1.TrySetFromTask(Task task, Boolean lookForOce)
at System.Threading.Tasks.UnwrapPromise`1.ProcessInnerTask(Task task)
at System.Threading.Tasks.Task.RunContinuations(Object continuationObject)
at System.Threading.Tasks.Task`1.TrySetResult(TResult result)
at System.Threading.Tasks.Task.TwoTaskWhenAnyPromise`1.Invoke(Task completingTask)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
--- End of stack trace from previous location ---
at Microsoft.Diagnostics.Monitoring.WebApi.ProfilerChannel.SendMessage(IEndpointInfo endpointInfo, IProfilerMessage message, CancellationToken token) in /_/src/Microsoft.Diagnostics.Monitoring.WebApi/ProfilerChannel.cs:line 41
at Microsoft.Diagnostics.Tools.Monitor.Stacks.StacksOperation.StacksOperationPipeline.StartAsync(CancellationToken token) in /_/src/Tools/dotnet-monitor/Stacks/StacksOperation.cs:line 85
at Microsoft.Diagnostics.Tools.Monitor.PipelineArtifactOperation`1.ExecuteAsync(Stream outputStream, CancellationToken token) in /_/src/Tools/dotnet-monitor/PipelineArtifactOperation.cs:line 48
at Microsoft.Diagnostics.Tools.Monitor.PipelineArtifactOperation`1.ExecuteAsync(Stream outputStream, CancellationToken token) in /_/src/Tools/dotnet-monitor/PipelineArtifactOperation.cs:line 55
at Microsoft.Diagnostics.Monitoring.WebApi.OutputStreamResult.<>c__DisplayClass6_0.<<ExecuteResultAsync>b__0>d.MoveNext() in /_/src/Microsoft.Diagnostics.Monitoring.WebApi/OutputStreamResult.cs:line 55
--- End of stack trace from previous location ---
at Microsoft.Diagnostics.Monitoring.WebApi.ActionContextExtensions.<>c__DisplayClass1_0.<<InvokeAsync>b__0>d.MoveNext() in /_/src/Microsoft.Diagnostics.Monitoring.WebApi/ActionContextExtensions.cs:line 121
--- End of stack trace from previous location ---
at Microsoft.Diagnostics.Monitoring.WebApi.ExecutionHelper.InvokeAsync[T](Func`2 action, ILogger logger, CancellationToken token) in /_/src/Microsoft.Diagnostics.Monitoring.WebApi/ActionContextExtensions.cs:line 45
at Microsoft.Diagnostics.Monitoring.WebApi.ActionContextExtensions.InvokeAsync(ActionContext context, Func`2 action, ILogger logger) in /_/src/Microsoft.Diagnostics.Monitoring.WebApi/ActionContextExtensions.cs:line 125
at Microsoft.Diagnostics.Monitoring.WebApi.OutputStreamResult.ExecuteResultAsync(ActionContext context) in /_/src/Microsoft.Diagnostics.Monitoring.WebApi/OutputStreamResult.cs:line 43
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultFilters>g__Awaited|28_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
Note: all other commands like /dump, /trace, etc work fine.
The issue is only with /stacks endpoint.
Configuration
- Windows 11, Version 23H2 (OS Build 22631.3593).
- Content of file settings.json:
{
"InProcessFeatures": {
"CallStacks": {
"Enabled": true
}
}
}
Welcome to dotnet-monitor!
Thanks for creating your first issue; let us know what you think of dotnet-monitor by filling out our survey.
Thanks for reporting this! Our in-process features aren't supported in the default Connect
mode, so you'll want to switch to the Listen
connection mode to use this feature. See our diagnostic port configuration docs for details on how to configure the connection mode and let us know if you have any issues with it!
With that said, dotnet-monitor returning a 500
when trying to use /stacks
in Connect
mode definitely isn't desired behavior. Ideally we'd return and/or log something more informative -- we'll take a look into fixing this experience
Thanks, yes in Listen
mode I was able to collect stack trace with this minimal configuration in settings.json:
{
"InProcessFeatures": {
"CallStacks": {
"Enabled": true
}
},
"DiagnosticPort": {
"ConnectionMode": "Listen",
"EndpointName": "/diag/port.sock"
}
}
I think it's useful to mention your suggestion in documentation for other people who may face with the same problem.
Please accept PR #6755 if it makes sense.