You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
computedFn uses _isComputingDerivation() to determine whether it should cache or not. However, when getting value of a computed from within an action, _isComputingDerivation() will return true and computedFn will cache the arguments it's called with. But since we're in an action, onBecomeUnobserved will never get called to evict the arguments from the cache.
I think you can (and probably should) do it the other way around - by checking you don't run in Reaction, in which case globalState.trackingContext === null IIRC.
Or you may consider caching the value for the duration of the batch, like computed does, but I don't know how you would go about that.
computedFn
uses_isComputingDerivation()
to determine whether it should cache or not. However, when getting value of a computed from within an action,_isComputingDerivation()
will returntrue
andcomputedFn
will cache the arguments it's called with. But since we're in an action,onBecomeUnobserved
will never get called to evict the arguments from the cache.Here's the smallest reproducible scenario I can come up with: https://codesandbox.io/s/computedfn-memory-leak-5xvsg6
I think it's similar to #116 (which has been mostly—but apparently not completely—fixed by #228).
Should there be a more reliable way than
_isComputingDerivation()
to determine whether we're running inside an action?The text was updated successfully, but these errors were encountered: