If you landed a good job afterwards, I’d say those four months were necessary and even beneficial. Sometimes your body/mind will simply force you to stop, and procrastination can be one of their tricks to convince you to do it.
I did need a break after my last job, and it's very possible that contributed to the problems I had, but this was definitely a bug, not a feature.