The Prophet ﷺ said, "When one of you grows drowsy, let him sleep until the drowsiness leaves him, for if he prays while drowsy he does not know what he is saying. He may intend to seek forgiveness and end up cursing himself instead."
حدثنا أبو بكر بن أبي شيبة حدثنا عبد الله بن نمير ح و حدثنا أبو مروان محمد بن عثمان العثماني حدثنا عبد العزيز بن أبي حازم جميعا عن هشام بن عروة عن أبيه
قال النبي ﷺ إذا نعس أحدكم فليرقد حتى يذهب عنه النوم فإنه لا يدري إذا صلى وهو ناعس لعله يذهب فيستغفر فيسب نفسه
[Sahih]. Narrated by Muslim, Book of the Traveler's Prayer, Chapter on the command for one who dozes off during prayer, etc., no. 786, from Abu Bakr bin Abu Shayba and others, with this wording. Also narrated by Bukhari, Book of Wudu, Chapter on wudu after sleep, etc., no. 212, and by Muslim and others, from the hadith of Malik, from Hisham, with this wording.