Open kumavis opened 6 years ago
We could probably fix this by using a WeakMap for the registry of remote references.
Actually we need to know when the returned proxy methods are garbage collected. As these events are happening in completely different runtimes (event on different machines), WeakMap alone is useless. I see 3 ways how this could be handled:
In real life most of the time returned objects are used in async contexts and should be disposed right after. Whenever the method should outlive async context, it must be explicitly assigned to some owner. So 3 looks like a solution.
Being able to return objects that are also RPCs is a really neat feature, but i discovered a gotcha.
Every time
abc
is called, a new remote referencexyz
will be created. These references don't have a lifecycle so they can never be cleaned up. Not really anything you can do about it, but worth documenting.