How to sleep when you have to solve bugs at night

Posted by makeevolution@reddit | ExperiencedDevs | View on Reddit | 50 comments

Sometimes work gets hard and hard bugs keep coming that I need more time to trial and error. Waiting for e.g. builds or deployments on every iteration costs time and I have to do this at night. The light from my monitor and stress makes it difficult for me to go to sleep, even if I found the solution to the bug, since they interrupt my melatonine production and sleep cycle. It's also sometimes hard for me to detach from it when I can't find the solution, causing me to go all in to the morning and didn't sleep at all.

For you guys experienced devs, any tips on how to relax quickly your nerves for sleep, so that you still wake up fresh the next day and can go to work?