fix infinite loop when a large number of files need to be compiled