nytimes / gziphandler

Go middleware to gzip HTTP responses
https://godoc.org/github.com/NYTimes/gziphandler
Apache License 2.0
868 stars 129 forks source link

Show the error of gw.Close() #89

Open humingcheng opened 5 years ago

humingcheng commented 5 years ago

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

go version go1.12.9 windows/amd64

What operating system and processor architecture are you using?

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\hmc\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\hmc\go
set GOPROXY=
set GORACE=
set GOROOT=C:\go
set GOTMPDIR=
set GOTOOLDIR=C:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\hmc~1\AppData\Local\Temp\go-build408318050=/tmp/go-build -gno-record-gcc-switches

What did you do?

I startded a http server with gzip handler, with the server's param WriteTimeout set to a certain value. Then I made a request who's handle time was longer than the WriteTimeout.

What did you expect to see?

Get some logs or errors about the WriteTimeout error.

What did you see instead?

Nothing. Only saw that the connection was closed and nothing responsed.

This issue is similar to net/http: ResponseWriter.Write does not error after WriteTimeout nor is ErrorLog used. But the difference is that, gw.Close() is called in a gzip handler and it returns an error, maybe there is a way to show the error or give it to users? In my scenario, gw.Close() returned an error of internal/poll.TimeoutError, and it helped me to find my server's issue. So I think showing the error of gw.Close() helps the users.