question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Return full stacktrace on service startup failures

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JamesNKcommented, Aug 10, 2022

I improved the example here - https://github.com/grpc/grpc-dotnet/pull/1841

0reactions
covecommented, Aug 10, 2022

Oh I see, I just copied the sample code verbatim and didn’t look too closely at it, so that’s where it’s getting dropped then:

       private void WriteMessage(LogLevel logLevel, string category, EventId eventId, string message, Exception? exception)
        {
            // Log using the passed in execution context.
            // In the case of NUnit, console output is only captured by the test
            // if it is written in the test's execution context.
            ExecutionContext.Run(_executionContext, s =>
            {
                Console.WriteLine($"{_stopwatch.Elapsed.TotalSeconds:N3}s {category} - {logLevel}: {message}");
            }, null);
        }

Also any thoughts on why the IConfiguration isn’t loading values from appsettings.json in the test?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get the full stacktrace of failed tests in failsafe?
I have a JUnit integration test that fails throwing an exception when executed by the Maven Failsafe plugin. I configured failsafe to write ......
Read more >
Is exposing exception information in web service a security ...
This question already has answers here:​​ On one hand exposing full stacktrace and even the message is risky since it might contain some...
Read more >
IIS get full error message for failed requests
I already set-up "Failed Request Tracing" but the directory remains empty. If possible I'd prefer to get the stack trace in the browser...
Read more >
Stack Trace: How to Debug Your Application With a ...
A stack trace can tell you a lot about the health of your application. Learn more about using a stack trace's valuable info...
Read more >
What is a Java Stack Trace? How to Read & Analyze Traces
The stack trace, also called a backtrace, consists of a collection of stack records, which store an application's movement during its execution.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found