OTOH, I remember handful of nights severely stuck on something, fighting sleep at 2 am trying to fix something, eventually saying "f work" and going to sleep.
Next morning, while in the shower, a possible solution had popped in my head out of thin air. By lunch I had solved it.
I now try the "sleep over it" approach before losing sleep over it.
Intermediate solution is to write down any ideas and then go back to sleep. That gets the ideas out of my head which for me is enough to calm down and go to sleep.