This is a common phenomena which most of us come across. Seeing flashes of light, stars and other shapes in the eyes occur when the body goes through stressful activities. For example while you are climbing the blood flow will be more to other prominent parts like hands and lower waist so brain and eyes will get less supply of blood as well as nutrients. Hence those flashes or stars are visible to us. This phenomena is called "Phosphene" and a phosphene is a phenomenon characterized by the experience of seeing light without light actually entering the eye.
Wikipedia/Phosphene gives an explanation for occurrence of Phosphenes:
Phosphene is "seeing stars", from a sneeze, laughter, a heavy and deep cough, blowing of the nose, a blow on the head or low blood pressure (such as on standing up too quickly or prior to fainting). It is possible these involve some mechanical stimulation of the retina, but they may also involve mechanical and metabolic (such as from low oxygenation or lack of glucose) stimulation of neurons of the visual cortex or of other parts of the visual system.
So seeing flashes of light can be due to:
- Blood shifting.
- Low blood sugar(causes weakness).
- Head trauma.
So to summarize this thing, we should have enough nutrients, water supply to the body whenever we come across stressful activities. Phosphenes are temporary stuff which do not harm eyes.