[whatwg] Define MessagePort.isConnected or MessagePort.ondisconnect

ATSUSHI TAKAYAMA taka.atsushi at googlemail.com
Mon Mar 15 18:07:17 PDT 2010


Thanks for replies,

I understood what's the problem here.

> The only option that comes to mind that doesn't expose compatibility issues
> would be to only issue onclose events if close() is explicitly called on the
> entangled port, but if you're doing that you might as well just have the
> code calling close() post a "I'm closing" message first.
> -atw

This would mean that all web pages using a SharedWorker (and keep
reference to MessagePort inside the SharedWorker) have to set "unload"
event handlers to call port.close() so that references to the ports in
the SharedWorker don't get accumulated. That is not desirable.
"pagehide" handler may not be sufficient for this purpose.

I think, as Hixie suggested, an array like object to track references
of all connected ports would be nice *for SharedWorkers*. For ports
created dynamically by new MessageChannel, it doesn't seem to work
well.

A. TAKAYAMA



More information about the whatwg mailing list