-
Notifications
You must be signed in to change notification settings - Fork 311
Use net.ErrClosed #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use net.ErrClosed #303
Conversation
99ea4f2
to
b509f6b
Compare
Like! |
Hi @nhooyr, any chance to get this reviewed? Thanks! |
Ping @nhooyr, would you have the time to have a look? |
Sorry for the delay I'm on a rather long sabbatical right now. Will review when I'm back by the end of this month! |
Cool! No problem, take your time :) |
Any news? |
Hi again @nhooyr, any chance to get this reviewed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both close__go113.go
and close__go116.go
has build tag
// +build !go1.16
One is missing a |
Sorry @emersion my sabbatical continues until at least mid October. Apologies for the delay and the broken promise above but I'm dealing with some personal stuff right now and was hoping to be back sooner. I could merge this as is into master as I don't see anything wrong with it but I can't do any sort of release without dealing with #256 first which will take substantial effort. So I'd prefer to leave this PR open as is until I'm back. |
No problem, thanks for having a look.
I'd personally prefer for this to be merged so that I can upgrade to the latest commit even if there's no release yet. But up to you! |
Hi @nhooyr, is it possible to merge this? |
Gentle ping |
@nhooyr, any chance to get this merged? |
Hi, any news about this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will get this merged in after #256
write.go
Outdated
@@ -53,14 +52,14 @@ type msgWriter struct { | |||
|
|||
func (mw *msgWriter) Write(p []byte) (int, error) { | |||
if mw.closed { | |||
return 0, errors.New("cannot use closed writer") | |||
return 0, errClosed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two are separate errors and should remain. They aren't the same as net.ErrClosed
.
write.go
Outdated
} | ||
return mw.mw.Write(p) | ||
} | ||
|
||
func (mw *msgWriter) Close() error { | ||
if mw.closed { | ||
return errors.New("cannot use closed writer") | ||
return errClosed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
Hm, why is that? |
Neither of those are closed connections, they're readers and writers for a single frame. There's only the one spot in |
Ah, I see, that makes sense! Fixed. |
+1 to this PR :) |
Can this thing go any further? |
Go 1.16 has introduced net.ErrClosed, which should be returned/wrapped when an I/O call is performed on a network connection which has already been closed. This is useful to avoid cluttering logs with messages like "failed to close WebSocket: already wrote close". Closes: coder#286
Sorry for the delays, thanks @emersion |
Go 1.16 has introduced net.ErrClosed, which should be returned/wrapped when an
I/O call is performed on a network connection which has already been closed.
This is useful to avoid cluttering logs with messages like "failed to close
WebSocket: already wrote close".
Closes: #286