Slow c++ compile when code contains compile errors?

I am developing a plugin. I found a strange thing that some times the compile is extremely slow, which takes over 3 minutes for very slightly change. After some experiment I found that visual studio will stuck at here when the code contains compile errors:

After about 3 min it comes up with:

How could I avoid compile errors eating up my time? Thanks for your help.

3 minutes are quite ok’ish if you ask me, UBT usually takes that much of first run of day, UHT may take some time too if you do changes in header file or introduce new files. People say VS2019 improve compile time but there also people reporting issues with it as it’s first version using that version of VS