golang/go

net/http: Client.Do returns different errors on context deadline depending on req/conn state

Open

#31,863 opened on May 6, 2019

View on GitHub
 (5 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
NeedsInvestigationhelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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

Does this issue reproduce with the latest release?

yes

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

What did you do?

Run multiple times program on my server (24 cpu) https://play.golang.org/p/d00_wxKDN5f With single goroutine - problem did not appears. Problem appeared not every run, but in 3-4 runs at least one was faulty.

What did you expect to see?

all goroutines: done = true, err = Get http://240.0.0.1/test: context deadline exceeded

What did you see instead?

all gouroutines returned at the same time, after 4 seconds, like i specified in parent context.WithTimeout. But some goroutines returned before parentContext.Done was closed (error was i/o timeout), and some gorotines returned after parentCtx.Done was closed (with expected error "context deadline exceeded").

Contributor guide