You can foresee and outbreak if you notice an abundance of tiny flying midge (look like small flies) near the biological treatment unit. The rapid life cycle of midge, ensures you have flying insects and larvae in conjunction with each other.
What can you do to prevent the biomass loss? Use EPA approved control methods such as Strike, an insect growth regulator, or Aquabac XT, a Bacillus thuringiensis spore solution that kills larvae by damaging the digestive tract. Using either product has given great results within a 2 - 5 days (another product of the rapid life cycle in midge flies). If the outbreak causes extreme loss of biomass, we often see ammonia removal efficiency drop (nitrifiers are very slow growers and susceptible to washout). In this case, you may want to add a floc forming bacterial inoculum such as Aster Bio's AB Munizyme that helps build MLVSS and prevents nitrifier washout. Adding, the more delicate (refrigerated/shipped overnight) and expensive nitrifier cultures is usually not needed as you can restore the population rapidly by just building good biomass.