-
Notifications
You must be signed in to change notification settings - Fork 25
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
don't drop CloseEvent silently #12
Conversation
if e.WasClean { | ||
cleanStmt = "clean" | ||
} else { | ||
cleanStmt = "unclean" | ||
|
||
if e.Reason != "" { | ||
console.Warn("original Reason:", e.Reason) |
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.
You'll want to get rid of any console debugging
I converted the string lookup to a map. It does look a lot cleaner. I kept the one |
I tried io.Pipe() and it is functional but I don't get the close error exposed when using the Maybe I don't understand the I'll setup a simpler test app that is |
} | ||
|
||
if e.Code == 1010 { | ||
reason += "\nSpecifically, the extensions that are needed are: " + e.Reason |
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.
This line will only execute when e.Reason
is the empty string. So you're effectively doing this:
reason += "\nSpecifically, the extensions that are needed are: " + ""
Perhaps this if e.Code == 1010 {
block should be in the if e.Reason != "" {
block instead?
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.
Oh right, that does nothing. Thanks @shurcooL.
Sadly I havn't seen a websocket implementation (on browser api level) that fills in those fields to acutally see how concatanating these would makes sense. In this case, if e.Reason
has more than a list of exensions in it, this would get ugly. I'll remove the if e.Code == 1010 {}
block until then.
What's the status here? This PR seems quite out of date, should we close it, or is there anything to do here?
|
Agreed |
Hi,
currently the event object of the close event is silently ignored and dropped. I use a
Conn
from this package to build anet/rpc
client and stumbled over this when I saw that uses of a closed connection returned an empty error. I can create a more verbose reproduction if needed.Furthermore, the reason string was empty but the code was set (for me at least on Linux with Chromium42 and Firefox37). I found a post on stackoverflow which had compiled the code>reason mapping from RFC6455.
I think a proper fix should also fix or improve #7 but I wanted feedback first on how to progress on both cleanly.