Hello,
I have an observable array. Objects there are loaded from a server when application starts and being added as well later. In both cases before adding an object to the array I populate it with additional fields.
I noticed that sometimes the fields that I add are missing and during an investigation it turned out that in such case they appear in pendingKeys map.
Could you please give me a direction where to look for a problem in my code that results in this behavior?
On the image below you can see the "good" object at index 0 and the "bad" object at index 1.

It is totally unclear to me what the problem is, could you follow the bug template and provide a sandbox reproduction and describe observed and expected behavior?
I am not complaining about a bug in MobX. The bug is probably somewhere in my code and I need a help from someone with the knowledge of the MobX internals in order to sort it out.
In short, my question is: what can cause keys that I add to an observable object to not appear on it, but instead appear in pendingKeys map.
Thank you.
And how do you suppose we can fix your code when you haven't shown any? 😆 Just use CodeSandbox and show us what you can or link the whole repo if you want, but point out precisely what is happening where.
pendingKeys are populated by keys that were accessed, but don't exist on the object yet:
const obj = observable({});
autorun(() => {
console.log(obj.nonExistingKey)
// now we know you're interested in 'nonExistingKey' (we place it in pendingKeys)
// so when you add the key later, autorun is notified and re-runs
});
pendingKeysare populated by keys that were accessed, but don't exist on the object yet:
Thank you very much. This is the answer that I was looking for. Now I know that I should look for a case when I do not add keys that I expect to be added.
When I seen them inside pendingKeys I didn't think that MobX might know about them in the way that you described, so for me the situation looked like I add them, but for some weird reason MobX handles them that way.
Now it is clear, that there is no black magic and the bug does not related to the MobX.
Most helpful comment
pendingKeysare populated by keys that were accessed, but don't exist on the object yet: