-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a close event to MessagePort #914
Comments
I'm very positive on this; I would plan to mark us as positive on this absent any other feedback. There is a lot of good discussion in the issue and explainer, so if anyone has any questions, I would check both of those out first. |
@smaug---- WDYT? |
Given that one can achieve this through WeakRefs already, I think this is reasonable. (unrelated fwiw, unload is not deprecated. That is a link to a chromium internal thing, not a spec level deprecation) |
whatwg/html#5869 tracks that, so I'd stick to treating that as a separate thing despite the normative and non-normative language around "DedicatedWorkerGlobalScope objects act as if they had an implicit MessagePort associated with them.". |
Request for Mozilla Position on an Emerging Web Specification
@
-mention GitHub accounts): @fergald @nononokamOther information
Currently, there is no timely and reliable way to detect when a MessagePort becomes disentangled, which makes it difficult to release resources associated with ports. This issue has a long discussion of the problem and potential solutions. Some users have used the unload event to detect disconnect, but it is deprecated. Therefore, The approach available now is to hold a MessagePort in WeakRef and periodically check if this port has been garbage collected by using deref() or to make use of a page-hide event, which is quite inefficient.
So, I propose adding a close event. For example, if there are two entangled ports, portA and portB, and portA is closed, the close event is fired on portB.
The text was updated successfully, but these errors were encountered: