3 ms·
The current proposals avoid this problem by requiring that objects held by weak references can only be observably collected between turns of the event loop. In
by wycats 14y ago
The current proposals avoid this problem by requiring that objects held by weak references can only be observably collected between turns of the event loop.
In short: whenever a WeakReference is dereferenced, a temporary strong reference to the object is created that is dropped at the end of the turn of the event loop.
There might still be non-determinism, but it is limited to the type that is already common in JS. Behavior across event turns (i.e. happening in asynchronous callbacks) cannot make any assumptions about what else may have happened between callback registration and callback execution.