comlink icon indicating copy to clipboard operation
comlink copied to clipboard

Make releaseProxy asynchronous

Open garethj2 opened this issue 2 years ago • 4 comments

When I was using Deno with comlink, its testing framework was detecting that MessagePorts weren't being closed properly. In an earlier version of comlink, one could await a call to releaseProxy to ensure resources were properly disposed. It seems like this as been lost along the way with the latest changes.

Indeed the finalizers are a great addition but to make the tests clean, I still want to call releaseProxy accordingly when managing resources. In order for this to happen, releaseProxy needs to return a promise so it can be awaited upon.

garethj2 avatar Mar 02 '23 08:03 garethj2

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Mar 02 '23 08:03 google-cla[bot]

It would be great to get this reviewed and submitted if possible.

garethj2 avatar May 19 '23 14:05 garethj2

Isn't the idea of releaseProxy to release references without caring about whether the other side responds or not?

Note: None of the other code uses async/await - I don't know if that's be design (sometimes done for performance) or not but wanted to point that out as well.

defunctzombie avatar Jan 20 '24 19:01 defunctzombie

@defunctzombie true but there are occasions where you want to watch for the proxy to be released.

My main use case was running unit tests in Deno. Without waiting for releaseProxy to complete, deno's unit test framework would complain about resource leaks. For most of the tests, I want to be able to start everything up and then shut everything down cleanly.

garethj2 avatar Jan 22 '24 09:01 garethj2