[whatwg] onclose events for MessagePort

Olli Pettay Olli.Pettay at helsinki.fi
Tue Oct 1 10:01:04 PDT 2013

On 10/01/2013 06:37 PM, Ehsan Akhgari wrote:
> Hi everyone,
> We're coming across a need to get notified when the other side of a channel
> goes away because the user navigates away from the page, or if the page is
> killed by the OS, etc.  Currently a workaround is for the application to
> handle the unload event and send a message on its channel letting the other
> side know that it's going to die, but that's obviously not good enough if
> the application is terminated abruptly (e.g., crashes.)
> We proposed an onclose event on MessagePort to handle this case [1] and it
> was rejected because that would make the GC behavior observable (in case
> the port on the other side is garbage collected.)  But it seems like tying
> the lifetime of MessagePorts to the lifetime of their owner document will
> fix that problem.
> Is that going to be an acceptable solution?

I don't understand what "the lifetime of MessagePorts to the lifetime of their owner document"
means in case of workers. And we sure want to delete MessagePort objects if nothing from JS side
is keeping it, or the port it is connected to alive.


> [1] https://www.w3.org/Bugs/Public/show_bug.cgi?id=23327
> Thanks!
> --
> Ehsan
> <http://ehsanakhgari.org/>

More information about the whatwg mailing list