[whatwg] onclose events for MessagePort

Gene Lian clian at mozilla.com
Wed Oct 2 05:02:38 PDT 2013


Hi guys,

Not really be able to follow all the details and technical terms. However, I'd also highly agree it's worth adding an onclose event to imply the aliveness of the owner (on the other end).

We can imagine in the future MessagePort will be a very generic structure utilised in lots of messaging purposes. If an API that wants to do the so-called *connection-oriented* messaging, the port had better need a way to know when the connection is being unexpectedly disconnected. If both of the owners are still alive, they can naturally use postMessage/onmessage to explicitly do the disconnection with each other.

However, what's happening if one of the owner has gone away without saying goodbye? For example, window can be closed when its owning process gets killed or crashed. Under the circumstances, the central/parent process is the only role to be aware of that and responsible for delivering the onclose event to the other end. From the point of view of implementation, it's definitely doable.

IMO, adding onclose event can make the MessagePort more flexible and more friendly to be applied in lots of messaging APIs. I'd vote for that.

Gene



More information about the whatwg mailing list