The contentious part of this question is the trigger for the Readied Action
The relevant rule for setting the trigger for a Readied Action is as follows:
When the trigger occurs, you can either take your reaction right after the trigger finishes or ignore the trigger. (PHB p. 193)
Xanathar's Guide to Everything elaborates further:
If you’re unsure when a reaction occurs in relation to its trigger, here’s the rule: the reaction happens after its trigger completes, unless the description of the reaction explicitly says otherwise.
So, does 'when the bandit throws a javelin, but before the javelin hits' work as a trigger?
It's not really clear, RAW.
It could be argued that, if someone sets this trigger as 'when the bandit throws a javelin' then the trigger is finished or completes as soon it leaves the bandit's hand, in which case the Readied Action will interrupt the bandit's Action and potential damage from it will be avoided before the roll is resolved, to know whether it would have hit or not.
However, it could also be argued, that the trigger completing or finishing in this case means the bandit's Attack completing or finishing (i.e. both hit and potential damage being resolved) before the reaction is triggered. Ruling this way would make readying the Catapult spell basically useless, as Casting Catapult on your next turn and keeping your reaction free would always be more efficient.
Which way you rule on this is up to you.
I personally, would want to reward creative thinking, and so would rule as follows in my own game:
It works, for the reasons you've stated:
- The Javelin is light enough to be catapulted (2 lb).
- The trigger for the readied Action is perceivable (the javelin being thrown).
- 3d8 might seem like a lot of damage (especially as the javelin itself would normally only do 1d6) but the enemy has a chance to save against it and it's no more damage than the caster would do by catapulting a rock they run past on their own turn. Readying the action just has the added bonus of doing the damage while also intercepting an incoming attack.
And I'd allow it, because I don't think doing so is overpowered:
In most situations Shield (also a first level spell) would be a better solution:
- Shield doesn't deal damage but would allow you to deflect multiple attacks (if you had multiple pursuers, or a pursuer with multi-attack) as it lasts until the start of your next turn. Catapult could only be cast once per round and the potential to deal damage (on a failed save) is only useful if reducing the attacker to 0 hp is likely.
- Shield doesn't consume your Action, meaning you could dash on your turn and cast Shield as a Reaction, therefore escaping any enemy that couldn't dash as a bonus action and kept throwing javelins. At 50 ft they'd already have disadvantage on javelin throws.
- When you Ready an Action to Cast a Spell (like Catapult) you effectively cast it on your turn (as a Cast a Spell Action) but then release it as a Reaction. That means you'd use the spell slot even if your trigger was never met. After the first time you catapulted a javelin back, an intelligent enemy might, rather than throwing another javelin, instead Dash to melee range. Then you'd have not only wasted an Action and burnt a spell slot for no gain, but you'd also provoke an Attack of Opportunity if you continued running.
- Finally, when you use Catapult, the enemy has the chance to save against your attack, and take no damage. So even in the fringe situation that you have only one pursuer, who can only make one attack per turn, who is near-death, and stupid enough to keep throwing javelins that you're firing back at them, you still risk burning actions and spell slots for little long-term gain.
P.S. An interesting aside, that hasn't been covered by this answer or any other, is that Catapult would probably break the javelin it was cast upon. Catapult deals 3d8 damage not only to whoever it hits, but also to the projectile itself. So, a DM would have to rule on how many hp a javelin had, but Catapult-ing it would almost certainly break it (for comparison, a Chain has 10 hp, a Rope only 2 hp).
This would prevent the same javelin being thrown back and forth, and mean that a pursuer would eventually run out of javelins in this situation - despite the fact that they are being 'returned to sender'. Whether a broken javelin could then be thrown as an improvised weapon is up to the DM (though it would still be a lesser damage die than an unbroken javelin, and have a smaller range).