go: net/http: TestRetryRequestsOnError failures with "use of closed network connection"

From https://storage.googleapis.com/go-build-log/c7862f5a/linux-amd64-race_4ed6f3c3.log

--- FAIL: TestRetryRequestsOnError (0.02s)
    --- FAIL: TestRetryRequestsOnError/NothingWrittenGetBody (0.00s)
        transport_test.go:3116: i=1: Do = Post http://fake.golang: read tcp 127.0.0.1:52650->127.0.0.1:42017: use of closed network connection; log:
            Dial
            Write("POST / HTTP/1.1\r\nHost: fake.golang\r\nUser-Agent: Go-http-client/1.1\r\nContent-Length: 4\r\nAccept-Encoding: gzip\r\n\r\nfoo\n")
            Handler
            intentional write failure
2019/03/19 21:17:09 http: TLS handshake error from 127.0.0.1:38418: write tcp 127.0.0.1:43483->127.0.0.1:38418: use of closed network connection

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 33 (28 by maintainers)

Commits related to this issue

Most upvoted comments

When a write fails, persistConn.roundTrip can learn of it in one of three ways:

This test failure occurs in the last case. It’s uncommon, because quite a lot needs to happen between the write loop signaling writeErrCh and roundTrip reading from it: The persistConn is closed, the read loop reads an error, the read loop sends on resc, and roundTrip reads from resc.