Yahya related to me from Malik from Hisham ibn Urwa from his father from A'isha, the wife of the Prophet ﷺ that the Messenger of Allah ﷺ said, "If you are drowsy in prayer, sleep until sleep leaves you, because if you pray while you are drowsy, you do not know whether you may intend to ask for forgiveness but (in fact) ask for harm."
أَنَّ رَسُولَ اللَّهِ ﷺ قَالَ إِذَا نَعَسَ أَحَدُكُمْ فِي صَلاَتِهِ فَلْيَرْقُدْ حَتَّى يَذْهَبَ عَنْهُ النَّوْمُ فَإِنَّ أَحَدَكُمْ إِذَا صَلَّى وَهُوَ نَاعِسٌ لاَ يَدْرِي لَعَلَّهُ يَذْهَبُ يَسْتَغْفِرُ فَيَسُبُّ نَفْسَهُ