Your eyes produce a small amount of mucus and oils to keep themselves moist, and since you don’t blink during sleep, this material accumulates in the corners of your eyes. The yellowish color typically comes from dead bacteria that your eyes have successfully fought off during the night.
It’s perfectly normal to experience this, and it’s your body’s way of clearing out anything that may have built up while you were sleeping. However, if the discharge is excessive or accompanied by symptoms like redness, itching, or burning, it could be a sign of an infection like conjunctivitis (pink eye), which may require medical attention.
The idea that this eye discharge is “casualties of a war” fought while you sleep, as Huberman puts it, might make you view it in a new, less gross light. After all, your body is working hard while you’re resting to keep your eyes healthy!