W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2010

[whatwg] Workers: What can be done in a worker after call to close()?

From: Jonas Sicking <jonas@sicking.cc>
Date: Thu, 1 Apr 2010 16:49:51 -0700
Message-ID: <t2z63df84f1004011649k4278d75ct44e7ab46e91cbe1@mail.gmail.com>
On Thu, Apr 1, 2010 at 4:40 PM, Drew Wilson <atwilson at google.com> wrote:
> How does the GC-initiated close() event work in Firefox, in the case of a
> fire-and-forget worker?
> For example:
> foo.html:
> <script>
> new Worker("forget.js");
> </script>
> forget.js:
> self.setInterval(function() { ...do something...}, 1000);
> In this case, it seems incorrect to ever fire a close() event until the
> parent window leaves the bfcache.?I'm guessing you must do something to
> prevent the worker object from being GC'd in the case that there's pending
> activity in the worker?

Indeed, such a worker would never be GC'd. Similarly a worker that
simply contains a infinite while(1) {} loop, or a worker that
continuously starts XHR requests at the end of the previous XHR

This isn't really related to the 'close' event though, but rather
worker lifetime.

The 'close' event would still fire at some point. Either if someone
calls terminate() from the outside, or once the user navigates away
from the page that started the worker.

/ Jonas
Received on Thursday, 1 April 2010 16:49:51 UTC

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