If you haven't found the solution to your problem for fourteen hours, the fifteenth one won't bring it either.
As a project manager for an IT company, sometimes I had to literally force the developers to shut off their computers and get some rest when they started to chase their own tails. Working long hours was disastrous for their productivity for multiple reasons:
Being up all night is absolutely destructive for your performance the following day. Sleep deprivation affects your attention, concentration and troubleshooting skills. With enough coffee you can survive the day after an all-nighter, but you will not be as productive as you might have been had you had a good night's sleep.
Higher error rate
When you are tired and defocused, you take your eye off the ball. You commit more errors or are unable to notice the mistakes due to sheer lack of concentration.
Neglected social life
Managing a healthy balance of your professional and private life is always a challenge, even more so if you work flexible hours. When you put all your resources into your work, not much is left for quality time with your family and friends.
Higher stress level
With fatigue, errors and unhappy relatives day in, day out, your mood can go downhill in no time. Higher stress level affects both mind and body and it's easy to fall into a vicious circle of being stressed of being constantly stressed.
Physical and mental exhaustion together with low performance at work may lead you to doubting your competence and your overall value as an employee. This is a straight road to job burnout, even if you genuinely like what you do and can't imagine yourself anywhere else.
Don't try to be a superhero. Do what needs to be done and do the best you can, but respect your physical and mental health.
What to do, then, when you are running like a hamster in a wheel and are not getting any closer to finding that one error in the code after a crazy number of hours? Here's the Three R's principle that I recommend to anyone who comes against a brick wall:
Relax. Refresh. Refocus.
In short, it means: take a nap. Go to sleep. Go outside and breathe. Take a walk. Read something. Meet a friend. Watch a movie. Do just anything to clear your mind and think about something absolutely work-unrelated. A pause will refresh your brain and give you new energy and perspective. When you're relaxed, it's easier to think outside the box and do things quicker.
In the long run, think of what you can do to avoid the necessity of staying up late. Discuss your workflow and time management with your colleagues, your boss or a coach and try to learn how to plan and execute your work strategy properly.
But first, a nap.
If there's one essential life skill that we can learn from cats, this is it: almost all problems can be slept through. Manage your energy well and don't waste your resources. If you want to get to that tuna can on the upper shelf, plan your jump carefully, execute it meticulously, enjoy your reward and relax.