handler icon indicating copy to clipboard operation
handler copied to clipboard

Logging Panic Stack Trace

Open johndww opened this issue 6 years ago • 2 comments

I'm looking to be able to log a stack trace when one of my field resolvers panics.

Currently, I get something like this:

        { "query": "query AllAttributes() {attributes(key: $value) {names}}", "variables": {}  } 
        
         [
        	{
        		"message": "runtime error: invalid memory address or nil pointer dereference",
        		"locations": []
        	}
        ]

I've tried to FormatErrorFn which works well for regular errors that get bubbled up, but by the time it gets triggered, the panic's stack trace is missing. I believe the defer-recover function in executor.go completeValueCatchingError would need to capture the stack in debug.Stack() and stash it on the gqlerrors.Error.

I'm happy to attempt to implement it and open a PR, but I'd like to make sure I wasn't missing something first.

johndww avatar Feb 01 '19 06:02 johndww

I have the same issue. It would be nice if this implementation is implemented :)

In the meantime, did you find a solution to show the stack trace?

PacoDw avatar Jan 05 '21 00:01 PacoDw

Hello, has this been implemented with #423? Is there an example of returning the stack when a nil pointer deref is hit?

Bjohnson131 avatar Sep 16 '21 03:09 Bjohnson131