<div>Hi!</div><div><br></div><div>Trying to fix some bugs for Workers, I&#39;ve got some questions about <a href="http://www.whatwg.org/specs/web-workers/current-work/#workerglobalscope">close() method on WorkerGlobalScope</a>.</div>
<div><br></div><div>In particular, the spec seems to imply that after calling close() inside the worker, the JS does not get terminated right away, but rather continue to execute, while an internal &#39;closing&#39; flag is set and a message queue associated with the worker discards all the tasks, existing and future. Also, all ports are immediately disentangled.</div>
<div><br></div><div>This seems to leave some questions without explicit answer, with differences in current implementations:</div><div><br></div><div>1. Does this code in a worker continues looping until the parent page unloads:</div>
<div> ...</div><div> close();</div><div> while(true) {}</div><div><br></div><div>WebKit V8 terminates, WebKit JCS terminates after a timeout, FF does not terminate.</div><div><br></div><div>2. Do the errors propagate back to Worker object after close()?</div>
<div>...</div><div>close();</div><div>nonExistingFunction();  &lt;&lt;-- throws, if not processed locally, posts error info to the Worker object.</div><div><br></div><div>In WebKit and FF errors propagate, although it does not seem consistent while worker closed all the ports and is in a dormant state.</div>
<div><br></div><div>3. Should synchronous operations work after close()? Asynchronous ones perhaps should not, because of the event loop queue which is stopped...</div><div>...</div><div>close();</div><div>xhr.open(&quot;GET&quot;, &quot;<a href="http://foo.com">foo.com</a>&quot;, <b>false</b>);</div>
<div>xhr.send();</div><div><br></div><div>WebKit: does not work (mostly), FF - does work.</div><div><br></div><div>Perhaps it would be simpler to either say nothing is executed/posted/fired after close() (immediate termination), or to enable worker run unimpeded (with ports open, etc) until it naturally yields from JS.</div>
<div><br></div><div>Any opinions?</div><div><br></div><div>Thanks,<br>Dmitry</div><div><br></div><div><br></div>