LossyRef, better than WeakRef

There are two time windows:

  1. Between the moment when the user code dropped its last reference to an object and when GC happens, and
  2. what you described: between when GC happens and when a FinalizaationRegistry callback happens.

Isn't it possible that before GC happens, inside of the the first time window, that a user can dereference a WeakRef and regain a reference back to an object, therefore preventing GC of the object and hence preventing the FinalizationRegistry callback, and that if a user loses and always re-gains an object reference in this manner before GC has a chance to run, that they will never collect the object?

Isn't that the problem that How to implement TwoWayWeakMap? Using WeakRef? has shown?

Let me know if you need me to show both the working and leaky examples here.