Skip to content

Intermittent timeout in /websockets/cookies/006.html #9803

Closed

Description

@nox
  ▶ TIMEOUT [expected OK] /websockets/cookies/006.html

  ▶ Unexpected subtest result in /websockets/cookies/006.html:
  │ TIMEOUT [expected PASS] WebSockets: setting Secure cookie with document.cookie, checking ws request
  └   → Test timed out

Activity

  1. added
    I-intermittent
    on Feb 29, 2016
  2. Manishearth commented on Feb 29, 2016

    @Manishearth
    Member

    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)

  3. jdm commented on Feb 29, 2016

    @jdm
    Member

    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).

  4. jdm commented on Feb 29, 2016

    @jdm
    Member

    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...

  5. Manishearth commented on Feb 29, 2016

    @Manishearth
    Member

    Huh, right.

  6. added a commit that references this issue on Feb 29, 2016
  7. added a commit that references this issue on Feb 29, 2016
  8. added a commit that references this issue on Feb 29, 2016
  9. bobthekingofegypt commented on Mar 12, 2016

    @bobthekingofegypt
    Contributor

    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.

  10. Manishearth commented on Mar 12, 2016

    @Manishearth
    Member

    Go ahead!

  11. bobthekingofegypt commented on Mar 14, 2016

    @bobthekingofegypt
    Contributor

    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?

  12. 8 remaining items

  13. jdm commented on Mar 28, 2016

    @jdm
    Member

    @bobthekingofegypt Absolutely! Use ./mach cargo-update -p websocket if you'd like to do so.

  14. nox commented on Mar 28, 2016

    @nox
    ContributorAuthor
  15. bobthekingofegypt commented on Mar 28, 2016

    @bobthekingofegypt
    Contributor

    @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?

  16. nox commented on Mar 28, 2016

    @nox
    ContributorAuthor

    @bobthekingofegypt I did a PR, see my previous comment. Nice work finding that fix btw.

  17. jdm commented on Mar 28, 2016

    @jdm
    Member

    @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.

  18. bobthekingofegypt commented on Mar 28, 2016

    @bobthekingofegypt
    Contributor

    @nox cheers.

    @jdm Sounds good.

  19. bobthekingofegypt commented on Mar 28, 2016

    @bobthekingofegypt
    Contributor

    @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

    //FIXME: Add support for wss
    

    Which suggests wss isn't supported yet.

  20. jdm commented on Mar 28, 2016

    @jdm
    Member

    I agree, that's pretty weird. It should be filed upstream in https://github.com/w3c/web-platform-tests/ though, and cc zcorpan.

  21. added
    C-disabled
    on Apr 22, 2016
  22. added a commit that references this issue on Jun 10, 2016
  23. mrobinson commented on May 23, 2025

    @mrobinson
    Member

    This test is no longer disabled, so likely isn't intermittent any longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-disabledI-intermittent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions