Considering your question and comment the problems happened before the river.
It was not A as in one costly mistake - it was series of mistakes. If you are kicking yourself for A mistake then you are kicking yourself for the wrong reasons.
... have a good hand pre-flop but hit nothing on the board. It's
worse if I've invested a lot already by the river
Why are you even in the river? Especially in the river with a lot invested. You have not hit the flop. You invest money at the flop and turn. Now you have a big pot at the river. You really think a donk is going to come off a big pot when they have shown strength?
If you don't hit the flop and someone shows strength then get away. A donk can by playing a range of hands and you did not hit. At that point there is very little in the pot. If you popped it pre flop and they called and then even more reason to get away if you don't hit. What you did was risk a lot of money to win a little with a low chance of success.
A good hand (overs) that does not hit by the river is the worse possible bluff. Donk hit a marginal flop and no scare cards come up so you bluff (a big pot) in desperation. If a scare card comes up that does not hit you then even more reason not to shove. A scare card only works if you set them up for it and you did not set them up.
Two overs with no possible straight or flush should not even be in a big pot at the river. Those are pots you want to keep small. If you hit an over you are not as likely get a big payout. You only want to build a big pot when you either have a monster or can hit a monster against a stack that may pay you off.
If you are isolated on a donk in position then the time to take a stab at it is the flop. Don't take donks to the river for a bluff - they are emotionally and financially committed by then (kind of sounds like you). If you are not isolated in position then again why are in the river with a big pot? Even then why a shove? A pot size bet is equally (in)effective.
A bluff is only effective if your opponent can put you on a better hand. Based on your question and comments you did not go through any of that thought process. It was not a bluff - it was a donation.
If you got stacked by a donk then you are not better than the average player at the table. That is not how you play a donk. Isolate, steal small pots without putting your stack at risk, and then take their stack with a monster.