Skip to content

Return full stacktrace on service startup failures #1839

@cove

Description

@cove

Is your feature request related to a problem? Please describe.

I'd like to see if service stacktraces can be bubbled up during service startup.

While writing integration tests for a service the gRPC call would fail with an unknown error and the detailed error messages and adding log interceptors didn't make it any clearer to me where the issue was. The root cause was IConfiguration wasn't being passed into my service on startup during the test so some values were null and causing the service to not start up, but if the stackstrace was easily available, without having to debug the pkg, it would have reduce the amount of code to look though for the cause.

Describe the solution you'd like

Specifically this call was discarding the stacktrace during startup due to the finally, could we catch the exception and bubble it up here?

        private async Task<TResponse> ResolvedInterceptorInvoker(TRequest resolvedRequest, ServerCallContext resolvedContext)
        {
            GrpcActivatorHandle<TService> serviceHandle = default;
            try
            {
                serviceHandle = ServiceActivator.Create(resolvedContext.GetHttpContext().RequestServices);
                return await _invoker(serviceHandle.Instance, resolvedRequest, resolvedContext);
            }
            finally
            {
                if (serviceHandle.Instance != null)
                {
                    await ServiceActivator.ReleaseAsync(serviceHandle);
                }
            }
        }

Describe alternatives you've considered

Log interceptors weren't that helpful since it doesn't tell you which code the error came from.

Additional context

It would also be nice if IConfiguration was injected during the test, but that's likely a different ticket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions