You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A-content/domInteracting with the DOM from web contentC-assignedThere is someone working on resolving the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the issI-refactorNo impact; the issue is one of maintainability or tidiness. Proposed solution requires refactoring.
move the fields of WebSocket that are only used by CloseTask into CloseTask (such as reason, clean_close, code, etc.) and add constructors with meaningful names as appropriate
Are there docs somewhere about how the task system interacts with the WebIDL bindings? I’m trying to understand when WebSocket::Close would be invoked in the current implementation.
The WebSocket::Constructor function fires CloseTasks (here and here) for different failure conditions.
Within WebSocket::Close, there's send_close function, which seems to interact with the underlying websocket client library to manage the close handshake.
Within the handler for CloseTask, it fires a CloseEvent.
There don't seem to be any other references to CloseTask, but it has some necessary logic from the spec. Would a CloseTask ever be fired through the JavaScript bindings? Or does that only trigger WebSocket::Close?
Those are great questions! I think the docs you're looking for are here. Specifically, JS code will only invoke methods that are part of the WebSocketMethods trait in this case. WebSocket::Close corresponds to ws.close(...) from JS.
ghost removed
C-assignedThere is someone working on resolving the issue
@anthgur / @Wafflespeanut / @jdm: Am I understanding the removal of C-assigned correctly, as meaning that this is no longer being worked on? If so, I'd like to take a crack at this.
@KiChjang: Yeah, apologies for the slowness, I got a bit blocked trying to figure out some wpt tests that I either broke or fixed, and then #8867 happened, so I'm currently re-working stuff to work on top of that. Planning on pushing something up this weekend!
@KiChjang / @jdm: I'm finally getting back to this, but I've run into something I could use some guidance on.
When I looked at this before, a tricky part of it was communicating the close code and reason between when the client starts the closing handshake, and when the server acknowledges it. But upon further reading of RFC 6455, section 7.1.5 states: "The WebSocket Connection Close Code is defined as the status code contained in the first Close control frame received by the application implementing this protocol." Section 7.1.6 makes a similar statement about close reason. My interpretation of this is that the code and reason used should be those received in a Close frame, rather than those sent.
The current implementation doesn't work that way, and my changes ran afoul of some of the WPT tests that check status codes, for instance this one. I tracked it down to this code in pywebsocket, which unconditionally sets the server's close code to 1000 and reason to "".
Am I misinterpreting the spec, or is the test implementation incorrect?
D'oh, my reading of the pywebsocket code was very poor – I see now that it's possible to override the close handler to make it echo code and reason from the client. But I'm still unsure whether doing so would make sense.
@jsanders Your reading of the spec looks correct to me. I'd be curious if it passes as written in Firefox and Chrome today, and tempted to modify the test server to echo the provided code and reason.
@jdm: Ok I'm glad I'm not crazy. Unfortunately, I get some sort of ssl cert error when running the test in Firefox locally, but on w3c-test.org, it fails in the way I expect:
That's exactly what I get with my patch to the behavior, so it seems like Firefox is interpreting it the same way, though I haven't dug into the code to be completely sure.
Chrome's behavior is wonkier – the close event ends up with code 1006 ("abnormal"). I thought maybe it was comparing the client and server codes and flagging it as abnormal if they don't match, but I hardcoded the server side to return 1005, and got the same results, so I'm not sure what to think.
I'll start looking into modifying the test server behavior.
@jdm: Alright, I think I figured this out. The confusion is that section 7.4.1 states that code 1005 is reserved to communicate that there was no code and should never actually be sent across the wire. So the right answer is to send nocode in this case, expect no code to be echoed back, and set the code of the event to 1005 to communicate that this is what happened. The WPT websocket echo handler still needs to be updated to work that way, though – currently it sends back 1000 instead of nothing. Do you think I should send that change upstream first, or include it in a PR here first?
A-content/domInteracting with the DOM from web contentC-assignedThere is someone working on resolving the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the issI-refactorNo impact; the issue is one of maintainability or tidiness. Proposed solution requires refactoring.
Activity
anthgur commentedon Oct 6, 2015
I'd like to work through this!
jdm commentedon Oct 6, 2015
That would be great!
anthgur commentedon Oct 18, 2015
Are there docs somewhere about how the task system interacts with the WebIDL bindings? I’m trying to understand when
WebSocket::Closewould be invoked in the current implementation.WebSocket::Constructorfunction firesCloseTasks(here and here) for different failure conditions.WebSocket::Close, there'ssend_closefunction, which seems to interact with the underlying websocket client library to manage the close handshake.There don't seem to be any other references to
CloseTask, but it has some necessary logic from the spec. Would aCloseTaskever be fired through the JavaScript bindings? Or does that only triggerWebSocket::Close?jdm commentedon Oct 18, 2015
Those are great questions! I think the docs you're looking for are here. Specifically, JS code will only invoke methods that are part of the
WebSocketMethodstrait in this case.WebSocket::Closecorresponds tows.close(...)from JS.jsanders commentedon Nov 30, 2015
@anthgur / @Wafflespeanut / @jdm: Am I understanding the removal of C-assigned correctly, as meaning that this is no longer being worked on? If so, I'd like to take a crack at this.
KiChjang commentedon Nov 30, 2015
@jsanders Yes that is correct, this issue is up for grabs. I'll mark this as assigned.
KiChjang commentedon Dec 17, 2015
@jsanders Any updates on this?
jsanders commentedon Dec 18, 2015
@KiChjang: Yeah, apologies for the slowness, I got a bit blocked trying to figure out some wpt tests that I either broke or fixed, and then #8867 happened, so I'm currently re-working stuff to work on top of that. Planning on pushing something up this weekend!
jsanders commentedon Jan 11, 2016
@KiChjang / @jdm: I'm finally getting back to this, but I've run into something I could use some guidance on.
When I looked at this before, a tricky part of it was communicating the close code and reason between when the client starts the closing handshake, and when the server acknowledges it. But upon further reading of RFC 6455, section 7.1.5 states: "The WebSocket Connection Close Code is defined as the status code contained in the first Close control frame received by the application implementing this protocol." Section 7.1.6 makes a similar statement about close reason. My interpretation of this is that the code and reason used should be those received in a Close frame, rather than those sent.
The current implementation doesn't work that way, and my changes ran afoul of some of the WPT tests that check status codes, for instance this one. I tracked it down to this code in pywebsocket, which unconditionally sets the server's close code to 1000 and reason to "".
Am I misinterpreting the spec, or is the test implementation incorrect?
jsanders commentedon Jan 11, 2016
D'oh, my reading of the pywebsocket code was very poor – I see now that it's possible to override the close handler to make it echo code and reason from the client. But I'm still unsure whether doing so would make sense.
jdm commentedon Jan 11, 2016
@jsanders Your reading of the spec looks correct to me. I'd be curious if it passes as written in Firefox and Chrome today, and tempted to modify the test server to echo the provided code and reason.
jsanders commentedon Jan 11, 2016
@jdm: Ok I'm glad I'm not crazy. Unfortunately, I get some sort of ssl cert error when running the test in Firefox locally, but on w3c-test.org, it fails in the way I expect:
That's exactly what I get with my patch to the behavior, so it seems like Firefox is interpreting it the same way, though I haven't dug into the code to be completely sure.
Chrome's behavior is wonkier – the close event ends up with code 1006 ("abnormal"). I thought maybe it was comparing the client and server codes and flagging it as abnormal if they don't match, but I hardcoded the server side to return 1005, and got the same results, so I'm not sure what to think.
I'll start looking into modifying the test server behavior.
jdm commentedon Jan 11, 2016
FWIW, I'd probably want to submit the changes to the test server upstream independently to ensure that the right eyes see those changes.
jsanders commentedon Jan 12, 2016
@jdm: Alright, I think I figured this out. The confusion is that section 7.4.1 states that code 1005 is reserved to communicate that there was no code and should never actually be sent across the wire. So the right answer is to send no
codein this case, expect nocodeto be echoed back, and set thecodeof the event to 1005 to communicate that this is what happened. The WPT websocket echo handler still needs to be updated to work that way, though – currently it sends back 1000 instead of nothing. Do you think I should send that change upstream first, or include it in a PR here first?jsanders commentedon Jan 12, 2016
@jdm: I went ahead and pushed that change, so you can take a look. It fixes my tests, and I believe it would make firefox pass more of these tests.
jdm commentedon Jan 12, 2016
I think I'd need to see how that change interacts with the other changes, since I still feel like I'm missing part of the picture here.
jsanders commentedon Jan 18, 2016
@jdm: Just pushed #9358, with all the changes for this.
Auto merge of #9358 - jsanders:refactor-websocket-closing, r=jdm