W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2009

[whatwg] [hybi] Races in websocket API?

From: Greg Wilkins <gregw@mortbay.com>
Date: Fri, 20 Nov 2009 15:10:34 +1100
Message-ID: <4B0616BA.2050009@mortbay.com>
Fumitoshi Ukai (????) wrote:
> On Thu, Nov 19, 2009 at 1:00 PM, Greg Wilkins <gregw at webtide.com
>      var ws = new WebSocket("ws://mysite.com
>     <http://mysite.com>","myprotocol");
> ...
>     So if the next line in the script is
>      ws.onopen=myopenfunc;
>     there is a race between if the onopen function will
>     be assigned and if the background connection has been established?
> I believe open event  is just queued at the moment, and it will be fired
> later when javascript becomes idle.

Unfortunately this does not appear to be the implementation in chrome
at least.  If you step through with a debugger, then the close happens
before my ws.onclose function is assigned, as thus it is never called.

Even if it was implemented as you say, I'm wondering if the API should
be less dependent on the single threaded nature of current javascript

Received on Thursday, 19 November 2009 20:10:34 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:19 UTC