- From: <bugzilla@jessica.w3.org>
- Date: Sat, 16 Apr 2011 02:11:09 +0000
- To: public-webapps@w3.org
http://www.w3.org/Bugs/Public/show_bug.cgi?id=12510 Summary: race condition: open before setting onopen Product: WebAppsWG Version: unspecified Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: WebSocket API (editor: Ian Hickson) AssignedTo: ian@hixie.ch ReportedBy: glenn@skynav.com QAContact: member-webapi-cvs@w3.org CC: mike@w3.org, public-webapps@w3.org As presently defined, WebSocket may establish a connection before onopen is set. Using the example found in Section 4: var socket = new WebSocket('ws://game.example.com:12010/updates'); socket.onopen = function () { setInterval(function() { if (socket.bufferedAmount == 0) socket.send(getUpdateData()); }, 50); }; In this case, the new websocket may transition to OPEN state prior to execution of the statement that sets the onopen property. For instance, this may occur when stepping through this JS code in a JS debugger, or when GC occurs between the constructor and the following statement. The WS API should be modified to separate construction from opening, e..g., following a paradigm similar to XHR in which case the above example would become: var socket = new WebSocket(); socket.onopen = function () { setInterval(function() { if (socket.bufferedAmount == 0) socket.send(getUpdateData()); }, 50); }; socket.open('ws://game.example.com:12010/updates'); Regards, Glenn Adams -- Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
Received on Saturday, 16 April 2011 02:11:11 UTC