http2: close Transport connection on write errors

When a new connection is created, and a write error occurs during the
initial exchange, the connection must be closed. There is no guarantee
that the caller will close the connection.

When a connection with an existing write error is used or being used, it
will stay in use until its read loop completes. Requests will continue
to use this connection and fail when writing its header. These
connections should be closed to force the cleanup in its readLoop.

Fixes golang/go#39337

Change-Id: I45e1293309e40629531f4cbb69387864f4f71bc2
Reviewed-by: Brad Fitzpatrick <>
Run-TryBot: Brad Fitzpatrick <>
TryBot-Result: Go Bot <>
Trust: Brad Fitzpatrick <>
Trust: Damien Neil <>
2 files changed
tree: cc29793eb826dabaf36b339b75ecf1541a076e62
  1. .gitattributes
  2. .gitignore
  9. bpf/
  10. codereview.cfg
  11. context/
  12. dict/
  13. dns/
  14. go.mod
  15. go.sum
  16. html/
  17. http/
  18. http2/
  19. icmp/
  20. idna/
  21. internal/
  22. ipv4/
  23. ipv6/
  24. lif/
  25. nettest/
  26. netutil/
  27. proxy/
  28. publicsuffix/
  29. route/
  30. trace/
  31. webdav/
  32. websocket/
  33. xsrftoken/

Go Networking

This repository holds supplementary Go networking libraries.


The easiest way to install is to run go get -u You can also manually git clone the repository to $GOPATH/src/

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see The main issue tracker for the net repository is located at Prefix your issue with “x/net:” in the subject line, so it is easy to find.