[whatwg] onclose events for MessagePort
ehsan at mozilla.com
Tue Oct 1 08:37:59 PDT 2013
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  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?
More information about the whatwg