Everything turned invalid after compiling code

I was in the process of adding a swing sound to a weapon, when the entire animation blueprint of the main character class turned invalid after compiling the C++ code, every node getting replaced by a new version of itself. It’s already happened a few times before, and it was solvable by disconnecting everything and reconnecting it to the new version, but it’s getting on my nerves. There has to be some way I can prevent this from happening again, right? Or at least some easier way to refresh all the nodes than doing it manually