Does this issue reproduce with the latest release?
Yes
What did you do?
Tried to write a test that checks whether a net.Conn is already closed by checking that calling Close returns an error and run it on wasm. See
|
if runtime.GOARCH == "wasm" { |
|
t.Skip("conn.Close does not error as expected when called multiple times on WASM") |
|
} |
for the current workaround.
What did you expect to see?
An error suggesting that the connection has already been closed, as is consistent with all other architectures tested.
What did you see instead?
No error.
Discussion
I think the offending code is here:
|
func (fd *netFD) Close() error { |
|
fd.closedMu.Lock() |
|
if fd.closed { |
|
fd.closedMu.Unlock() |
|
return nil |
|
} |
On unix platforms the behaviour is to return internal/poll.ErrNetClosing or internal/pool.ErrFileClosing:
|
func (fd *FD) Close() error { |
|
if !fd.fdmu.increfAndClose() { |
|
return errClosing(fd.isFile) |
|
} |
|
func errClosing(isFile bool) error { |
|
if isFile { |
|
return ErrFileClosing |
|
} |
|
return ErrNetClosing |
|
} |
Does this issue reproduce with the latest release?
Yes
What did you do?
Tried to write a test that checks whether a
net.Connis already closed by checking that callingClosereturns an error and run it on wasm. Seego/src/crypto/tls/handshake_server_test.go
Lines 1980 to 1982 in 5d5f779
What did you expect to see?
An error suggesting that the connection has already been closed, as is consistent with all other architectures tested.
What did you see instead?
No error.
Discussion
I think the offending code is here:
go/src/net/net_fake.go
Lines 110 to 115 in 5d5f779
On unix platforms the behaviour is to return
internal/poll.ErrNetClosingorinternal/pool.ErrFileClosing:go/src/internal/poll/fd_unix.go
Lines 93 to 96 in 5d5f779
go/src/internal/poll/fd.go
Lines 42 to 47 in 5d5f779