It is narrated from Sayyidah Aisha (may Allah be pleased with her) that the Noble Prophet (peace and blessings be upon him) said: "When any one of you feels drowsy while praying, he should sleep until the sleepiness goes away, because it is possible that instead of seeking forgiveness, he may curse himself."
Hadith Referenceسنن دارمي / من كتاب الصللاة / 1421
(Commentary on Hadith 1420) The instruction to sleep when drowsiness overtakes one during prayer pertains to voluntary (nafl) prayers. For obligatory (fard) prayers and congregational prayer (jama‘ah), it is necessary to remain awake, and one should perform ablution (wudu) properly to dispel sleep, drowsiness, and lethargy.