I feel like a failed

So I'm breastfeeding. And I'm really trying to stick to it. During the day it's super easy but at night it becomes alot. Today we're going through cluster feeds (I'm thinking growth spurt) and for 4 hours he just wouldn't sleep and kept wanting more and more and I'm tapped out. I know it's supply and demand but I'm so tired. He's a horrible sleeper. Just wants to be held and I don't feel comfortable cosleepying when he's this young. So I just got frustrated and grabbed some ready to use formula. I just need to sleep. I know I'm messing up and I feel stupid cause I don't want my supply to suffer but I just couldn't do another hour or crying/thrashing at my breast. (I know I have a good supply so it's not low supply he's just going through a growth spurt) I just feel stupid for caving in cause I'm tired.