Skip to content
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. #271

Open
nononokam opened this issue Oct 24, 2023 · 2 comments
Open

Add a close event to MessagePort. #271

nononokam opened this issue Oct 24, 2023 · 2 comments

Comments

@nononokam
Copy link

nononokam commented Oct 24, 2023

WebKittens

@annevk

Title of the spec

MessagePort close event

URL to the spec

https://html.spec.whatwg.org/multipage/web-messaging.html#message-ports

URL to the spec's repository

No response

Issue Tracker URL

whatwg/html#1766

Explainer URL

https://github.com/fergald/explainer-messageport-close

TAG Design Review URL

No response

Mozilla standards-positions issue URL

No response

WebKit Bugzilla URL

No response

Radar URL

No response

Description

Currently, there is no timely and reliable way to detect when a MessagePort becomes disentangled. This makes it difficult to release resources associated with ports. 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.

@Ahmad-S792
Copy link

@annevk
Copy link
Contributor

annevk commented Jun 7, 2024

Note that there's an unresolved issue with this feature: whatwg/html#10201.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants