I've been experiencing this as well. I add a large amount of code. I press "Validate HTML", a whole series of variables are listed as undefined. Alternatively, I try to approve and close, and it notes that one variable is undefined. I check those variables and they appear to be fine.
But if I wait a couple of minutes and try to approve and close again, it closes without issue and the template functions exactly as expected.
I think it's just grinding through the code and needs time. If that's the case, it would be great to have something on the front end that would indicate that. (Grayed out/locked code editor with processing icon or something.)
It happens frequently indeed. This is because you try to approve it before it is saved to the back-end database. The "approve" function seems to run faster than the auto-save one in fact