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

net/http: TimeoutHandler hides panic locations #27375

Open
pvhau opened this Issue Aug 30, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@pvhau

pvhau commented Aug 30, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

v1.10.3

Does this issue reproduce with the latest release?

Not sure, I am finding a solution with my current version

What operating system and processor architecture are you using (go env)?

OS: linux, arch: amd64

What did you do?

This is a demo


import (
	"log"
	"net/http"
	"time"
)

type sampleHandler string
func (s sampleHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
	var mm interface{}
	log.Print("This will be panic")
	log.Print(mm.(string))
}

func main() {
	go func() {
		http.ListenAndServe("localhost:8888", http.TimeoutHandler(sampleHandler("sample"), time.Second*10, "Timeout"))
	}()

	time.Sleep(time.Second * 2)
	http.Get("http://localhost:8888/")
}

What did you expect to see?

I expect to see stack trace point to where cause panic (log.Print(mm.(string))) so that I can debug app easily

What did you see instead?

Stack trace point me panic(p) statement in net/http.timeoutHandler (go/src/net/http/server.go:3144). I know it make sense because that is the place that call panic. Are there any good solution to passing stack trace from handler inside TimeoutHandler?

@pvhau pvhau changed the title from Passing panic stack trace inside TimeoutHandler to Passing panic's stacktrace inside TimeoutHandler Aug 30, 2018

@FiloSottile FiloSottile added this to the Unplanned milestone Aug 31, 2018

@FiloSottile FiloSottile changed the title from Passing panic's stacktrace inside TimeoutHandler to net/http: TimeoutHandler hides panic locations Aug 31, 2018

@FiloSottile

This comment has been minimized.

Member

FiloSottile commented Aug 31, 2018

/cc @bradfitz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment