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
{{ message }}
Repository navigation
Intermittent timeout in /websockets/cookies/006.html #9803
This is a fun one. document.cookie works by sending a SetCookiesForUrl message to the resource task. This will be at some point handled by an event loop which will dump the cookies to the cookie jar.
On the other hand, websockets do not participate in this event loop, and read from the cookie jar directly. The cookie jar is behind a mutex so this is still safe.
The existence of the two synchronization mechanisms breaks the happens-before (e.g. a setcookies message is queued but the websocket reads directly from the jar first)
Actually, I'm not sure why we still don't have happens-before if document.cookie is set before creating the WebSocket. The resource thread is in charge of processing both the SetCookiesForUrl and WebsocketConnect messages, so the cookies would be updated before the connection is initiated...
I had some time to have a look at this one yesterday, might not get a chance again till later in the week.
I had a question about the test itself; this test appears to have the code branches for when the SCHEME_DOMAIN_PORT is set to 'wss' and also when it's not. As it's testing that secure cookies are sent on wss and not on ws. Looking at the other tests they usually have a separate test for each case, is there a reason that this one contains both paths, does it somehow get run both ways?
tl;dr - I have found a possible cause, but not a fix.
What follows is a dump of my current thoughts.
I have found a couple of things so far, first one I think is a bug in Servo's handling of client initiated close events. I don't know if this should maybe be a separate issue, or I may just be wrong it would be good if someone could verify, but...
There are two ways to cleanly disconnect the websocket, client initiated and server initiated. Server initiated looks like it should work fine but client initiated will not. This isn't terminal but results in unnecessary things being sent in the channel.
Steps in client close:
javascript calls websocket.close()
calls Close in components/script/dom/websocket.rs
Close function sets ready state to closing
Close function sends the WebSocketDomAction::Close event
components/net/websocket_loader picks up the event and sends the close message down the socket
pywebsocket correctly echos back the close
components/net/websocket_loader picks up the echo'd back close
identifies the opcode as Close and then incorrectly echo's the close back again
pywebsocket huffs and sends back an http error
I think this may effect some of the other intermittent websocket tests that are listening for onclose/onerror but I haven't checked them yet.
Now the part that is stumping me a bit. I have found a possible cause for the intermittent in this issue but I need to verify why that might have caused an issue. Normally when you run this test everything is fine, it does a couple of things
handshake
echo cookie back
send a close op to the client
Normally this will happen over a minimum of 4 separate TCP packets; websocket upgrade, text response, close, close(masked from client).
However when the test fails the wpt python sever does something a bit different, it decides to embed the text and close websocket packets inside one TCP packet. This could be a red herring as it should work fine, each websocket packet is framed individually so should be parsable. But it seems very co-incidental that it happens everytime there is a failure. I guess the next step would be to checkout rust-websocket and see what is happening in their. Does anyone else have any idea's why this might cause an issue, or seen something like it before? Or am I chasing a ghost by following this path?
With the other issue I found earlier, incorrect client close handling (#9803 (comment)). Do you have an idea for how that should be solved? Should a guard be replicated on the websocket_loader side of the channel that replicates the behaviour from the script/dom/websocket side? Or should the ready_state be shared somehow between the two?
@bobthekingofegypt Perhaps we should just store a boolean indicating that we're waiting to see a Close opcode from the server and avoid echoing it if that's the case.
@jdm well I remember, I asked this previously but I'm still unsure about this test case itself.
I had a question about the test itself; this test appears to have the code branches for when the SCHEME_DOMAIN_PORT is set to 'wss' and also when it's not. As it's testing that secure cookies are sent on wss and not on ws. Looking at the other tests they usually have a separate test for each case, is there a reason that this one contains both paths, does it somehow get run both ways?
The constants.js file for the websocket tests also contains the fixme
Activity
Manishearth commentedon Feb 29, 2016
This is a fun one.
document.cookieworks by sending aSetCookiesForUrlmessage to the resource task. This will be at some point handled by an event loop which will dump the cookies to the cookie jar.On the other hand, websockets do not participate in this event loop, and read from the cookie jar directly. The cookie jar is behind a mutex so this is still safe.
The existence of the two synchronization mechanisms breaks the happens-before (e.g. a setcookies message is queued but the websocket reads directly from the jar first)
jdm commentedon Feb 29, 2016
The fix for this and #9772 is to undo the cookie-related parts of #7654 (HSTS is fine because only the network stack interacts with it).
jdm commentedon Feb 29, 2016
Actually, I'm not sure why we still don't have happens-before if
document.cookieis set before creating the WebSocket. The resource thread is in charge of processing both theSetCookiesForUrlandWebsocketConnectmessages, so the cookies would be updated before the connection is initiated...Manishearth commentedon Feb 29, 2016
Huh, right.
Vindictively disable all intermittent tests that failed servo#9787
Auto merge of #9804 - nox:vengeful-disabling, r=KiChjang
Vindictively disable all intermittent tests that failed servo#9787
Vindictively disable all intermittent tests that failed servo#9787
Auto merge of #9804 - nox:vengeful-disabling, r=KiChjang
Vindictively disable all intermittent tests that failed servo#9787
Auto merge of #9804 - nox:vengeful-disabling, r=KiChjang
bobthekingofegypt commentedon Mar 12, 2016
Is it ok if I try to take a look at these intermittent websocket issues?
There seems to be a few, I think are probably all related.
Manishearth commentedon Mar 12, 2016
Go ahead!
bobthekingofegypt commentedon Mar 14, 2016
I had some time to have a look at this one yesterday, might not get a chance again till later in the week.
I had a question about the test itself; this test appears to have the code branches for when the SCHEME_DOMAIN_PORT is set to 'wss' and also when it's not. As it's testing that secure cookies are sent on wss and not on ws. Looking at the other tests they usually have a separate test for each case, is there a reason that this one contains both paths, does it somehow get run both ways?
tl;dr - I have found a possible cause, but not a fix.
What follows is a dump of my current thoughts.
I have found a couple of things so far, first one I think is a bug in Servo's handling of client initiated close events. I don't know if this should maybe be a separate issue, or I may just be wrong it would be good if someone could verify, but...
There are two ways to cleanly disconnect the websocket, client initiated and server initiated. Server initiated looks like it should work fine but client initiated will not. This isn't terminal but results in unnecessary things being sent in the channel.
Steps in client close:
I think this may effect some of the other intermittent websocket tests that are listening for onclose/onerror but I haven't checked them yet.
Now the part that is stumping me a bit. I have found a possible cause for the intermittent in this issue but I need to verify why that might have caused an issue. Normally when you run this test everything is fine, it does a couple of things
Normally this will happen over a minimum of 4 separate TCP packets; websocket upgrade, text response, close, close(masked from client).
However when the test fails the wpt python sever does something a bit different, it decides to embed the text and close websocket packets inside one TCP packet. This could be a red herring as it should work fine, each websocket packet is framed individually so should be parsable. But it seems very co-incidental that it happens everytime there is a failure. I guess the next step would be to checkout rust-websocket and see what is happening in their. Does anyone else have any idea's why this might cause an issue, or seen something like it before? Or am I chasing a ghost by following this path?
8 remaining items
jdm commentedon Mar 28, 2016
@bobthekingofegypt Absolutely! Use
./mach cargo-update -p websocketif you'd like to do so.nox commentedon Mar 28, 2016
#10240
bobthekingofegypt commentedon Mar 28, 2016
@jdm will take a look at doing that later.
With the other issue I found earlier, incorrect client close handling (#9803 (comment)). Do you have an idea for how that should be solved? Should a guard be replicated on the websocket_loader side of the channel that replicates the behaviour from the script/dom/websocket side? Or should the ready_state be shared somehow between the two?
nox commentedon Mar 28, 2016
@bobthekingofegypt I did a PR, see my previous comment. Nice work finding that fix btw.
jdm commentedon Mar 28, 2016
@bobthekingofegypt Perhaps we should just store a boolean indicating that we're waiting to see a Close opcode from the server and avoid echoing it if that's the case.
bobthekingofegypt commentedon Mar 28, 2016
@nox cheers.
@jdm Sounds good.
bobthekingofegypt commentedon Mar 28, 2016
@jdm well I remember, I asked this previously but I'm still unsure about this test case itself.
The constants.js file for the websocket tests also contains the fixme
Which suggests wss isn't supported yet.
jdm commentedon Mar 28, 2016
I agree, that's pretty weird. It should be filed upstream in https://github.com/w3c/web-platform-tests/ though, and cc zcorpan.
Auto merge of #10382 - bobthekingofegypt:fix-websocket-close, r=metajack
servo: Merge #10382 - stop client websocket close echoing server clos…
servo: Merge #10382 - stop client websocket close echoing server clos…
servo: Merge #10382 - stop client websocket close echoing server clos…
mrobinson commentedon May 23, 2025
This test is no longer disabled, so likely isn't intermittent any longer.