[whatwg] onclose events for MessagePort

Ehsan Akhgari ehsan at mozilla.com
Tue Oct 1 08:37:59 PDT 2013


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?

[1] https://www.w3.org/Bugs/Public/show_bug.cgi?id=23327

Thanks!
--
Ehsan
<http://ehsanakhgari.org/>


More information about the whatwg mailing list