I would not make a habit of this, as the light can stop the night cycle of the plant’s development, or cause unstable strains to herm.
That being said, any good breeder will intentionally light stress their plants so they can weed out the ones that will herm. Everyone’s left a door open or made some lighting mistake sometimes, and it shouldn’t negatively affect a true female plant.
The bigger issue is spraying for bugs during flower is not good at all. Preventative IPM’s before the buds start to form is a good practice so your plants don’t get bugs, but if you’ve already got bugs than you’re kind of already screwed.