Yes, desertion was always a problem, but in pre-modern battles there would usually be a lot more of your people behind you, making it hard to get away. Stuck between a spear and a hard shield.
http;//www.acoup.blog had some excellent posts about this recently.
http;//www.acoup.blog had some excellent posts about this recently.