Skip to content

Commit a42573c

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
net: avoid darwin/arm64 platform bug in TestCloseWrite
On darwin_arm64, reading from a socket at the same time as the other end is closing it will occasionally hang for 60 seconds before returning ECONNRESET. (This is a macOS issue, not a Go issue.) Work around this condition by adding a brief sleep before the read. Fixes #49352 (we hope). Updates #37795. Change-Id: I4052aec21d311d7370550aea9dd7941f39141133 Reviewed-on: https://go-review.googlesource.com/c/go/+/414534 Run-TryBot: Bryan Mills <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Damien Neil <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 68289f3 commit a42573c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/net/net_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ func TestCloseWrite(t *testing.T) {
9797
t.Error(err)
9898
return
9999
}
100+
101+
// Workaround for https://go.dev/issue/49352.
102+
// On arm64 macOS (current as of macOS 12.4),
103+
// reading from a socket at the same time as the client
104+
// is closing it occasionally hangs for 60 seconds before
105+
// returning ECONNRESET. Sleep for a bit to give the
106+
// socket time to close before trying to read from it.
107+
if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
108+
time.Sleep(10 * time.Millisecond)
109+
}
110+
100111
if !deadline.IsZero() {
101112
c.SetDeadline(deadline)
102113
}

0 commit comments

Comments
 (0)