Go net/http regression notes (NOT filed upstream: Paul's call, 2026-11-11). This is the draft and the repro, kept here only. The pin is branch go-pin-1.26.10. Drop it once a Go 1.26.12 or 1.27.5 changelog entry fixes net/http body locking, with TestDemoAPIAliasStreaming's early subtests as the witness.
net/http: server deadlocks writing a response while a concurrent goroutine reads an Expect: 100-continue body (regression in 1.26.11)
Go version
go1.26.11, go1.27.3, go1.27.4 (linux/amd64 and linux/arm64). go1.26.10 is fine.
What did you do?
A handler starts a goroutine that reads the request body (as httputil.ReverseProxy's Transport writeLoop does) and then writes an early response (e.g. a 401 from the backend) before the client has sent any body. The client sent Expect: 100-continue.
// A handler that answers while another goroutine is still reading the
// request body (as httputil.ReverseProxy does when the backend replies
// early) hangs on Go 1.26.11 when the client sent Expect: 100-continue.
package main
import (
"fmt"
"io"
"net/http"
"net/http/httptest"
"os"
"time"
)
func main() {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
go io.Copy(io.Discard, r.Body) // a concurrent reader, blocked: the client sends nothing yet
time.Sleep(100 * time.Millisecond)
w.WriteHeader(http.StatusUnauthorized) // the early refusal
io.WriteString(w, "no")
}))
defer ts.Close()
pr, pw := io.Pipe() // an upload that has not started
defer pw.Close()
req, _ := http.NewRequest("POST", ts.URL, pr)
req.Header.Set("Expect", "100-continue")
done := make(chan error, 1)
go func() {
resp, err := http.DefaultClient.Do(req)
if err == nil {
fmt.Println("status", resp.StatusCode)
resp.Body.Close()
}
done <- err
}()
select {
case err := <-done:
fmt.Println("ok, err =", err)
case <-time.After(3 * time.Second):
fmt.Println("HANG: no response after 3s")
os.Exit(1)
}
}
What did you see happen?
On go1.26.11 the response is never sent: HANG: no response after 3s. A goroutine dump shows conn.serve → response.finishRequest → chunkWriter.Write → chunkWriter.writeHeader → body.bodyRemains waiting on body.mu, which body.Read holds while it is blocked on the network inside expectContinueReader.Read.
What did you expect to see?
status 401, as on go1.26.10, where the check was the lock-free expectContinueReader.sawEOF. The change appears to come from the server.go refactor that went into 1.26.11 with the GO-2026-6859 fix (w.ecReader != nil && w.reqBody.bodyRemains() in writeHeader).