The Messenger of Allah ﷺ said, "When a man becomes drowsy while praying, let him stop and leave, for he may be supplicating against himself without realizing it."
أخبرنا بشر بن هلال قال حدثنا عبد الوارث عن أيوب عن هشام بن عروة عن أبيه
قال رسول الله ﷺ إذا نعس الرجل وهو في الصلاة فلينصرف لعله يدعو على نفسه وهو لا يدري
No references are available.
Bukhari narrated it in the Book of Wudu, Chapter on Wudu after Sleep and on Those Who Did Not Consider It Necessary, etc, hadith 786, from the hadith of Hisham with the same chain. Muslim also narrated it in the Book of the Prayer of Travelers, Chapter on the Command for One Who Becomes Drowsy During His Prayer, at length, and it is in al-Kubra, hadith 154.Ibn Khuzayma also narrated it, hadith 907, from Bishr bin Hilal with the same chain.