The Messenger of Allah ﷺ said, "When one of you grows drowsy while praying, let him lie down to sleep until the drowsiness leaves him. For if one of you prays while feeling drowsy, he may intend to seek forgiveness but end up cursing himself instead."
حدثنا هارون بن إسحق الهمداني حدثنا عبدة بن سليمان الكلابي عن هشام بن عروة عن أبيه
قال رسول الله ﷺ إذا نعس أحدكم وهو يصلي فليرقد حتى يذهب عنه النوم فإن أحدكم إذا صلى وهو ينعس لعله يذهب يستغفر فيسب نفسه
Agreed upon [by Bukhari and Muslim]. Bukhari narrated it in the Book of Wudu, chapter on wudu after sleep and on those who did not consider it necessary, etc., hadith no. 212, and Muslim, hadith no. 786, both from Hisham bin Urwa through this chain.On this subject there are also narrations from Anas [Bukhari, no. 1150, Muslim, no. 784] and from Abu Hurairah [Muslim, no. 787].