- From: Jonas Sicking <jonas@sicking.cc>
- Date: Thu, 21 Aug 2008 17:17:06 -0700
There is a race condition in proposed new Web Workers spec. The return value from postMessage can in some cases be true, even if the worker never receives the message. For example: main.js: w = new DedicatedWorker("worker.js"); if (w.postMessage("hello there")) { alert("success!!"); } worker.js: close(); If the postMessage is called before the worker has executed the 'close()' call the function will return true. But if the worker starts up fast enough and calls close(), the function will return false. To put it another way. Even if the worker is currently up and running when postMessage is called, there is no guarantee that the worker will run long enough to actually get to process the message. The only solution I can see is making postMessage return void. What use cases require knowing that the postMessage succeeds? / Jonas
Received on Thursday, 21 August 2008 17:17:06 UTC