Skip to content
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 timing out instantly #14568

Closed
dim opened this issue Feb 29, 2016 · 5 comments

Comments

Projects
None yet
4 participants
@dim
Copy link

commented Feb 29, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
go version go1.6 linux/amd64
  1. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GORACE=""
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
  1. What did you do?
    (Use play.golang.org to provide a runnable example, if possible.)
    http://play.golang.org/p/K9IgiTNaFk
  2. What did you expect to see?
    204 No content
  3. What did you see instead?
    503 Service Unavailable

It looks like the timer of the timoutHandler is created when the handler is wrapped in

t := time.NewTimer(dt)
. By the time the request is actually made, timer.C will have already triggered.

@ianlancetaylor ianlancetaylor changed the title TimeoutHandler timing out instantly net/http: TimeoutHandler timing out instantly Feb 29, 2016

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Feb 29, 2016

CC @bradfitz

This may be a documentation issue rather than a bug. I'm not sure.

@cmarcelo

This comment has been minimized.

Copy link
Contributor

commented Feb 29, 2016

@gopherbot

This comment has been minimized.

Copy link

commented Feb 29, 2016

CL https://golang.org/cl/20046 mentions this issue.

syncore added a commit to syncore/qlsbridge that referenced this issue Mar 7, 2016

Work around golang bug (golang/go#14568) that causes instant timeout …
…of http requests when handler is registered; add IP field to JSON for use with indexing for front-end
@cmarcelo

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2016

@bradfitz ping

@gopherbot

This comment has been minimized.

Copy link

commented Apr 19, 2016

CL https://golang.org/cl/22274 mentions this issue.

gopherbot pushed a commit that referenced this issue Apr 19, 2016

[release-branch.go1.6] net/http: TimeoutHandler should start timer wh…
…en serving request

TimeoutHandler was starting the Timer when the handler was created,
instead of when serving a request. It also was sharing it between
multiple requests, which is incorrect, as the requests might start
at different times.

Store the timeout duration and create the Timer when ServeHTTP is
called. Different requests will have different timers.

The testing plumbing was simplified to store the channel used to
control when timeout happens. It overrides the regular timer.

Fixes #14568.

Change-Id: I4bd51a83f412396f208682d3ae5e382db5f8dc81
Reviewed-on: https://go-review.googlesource.com/20046
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/22274
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>

@golang golang locked and limited conversation to collaborators Apr 19, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.