The Gemara in Succah (53a) quotes R’ Yehoshua ben Chananya who says: כשהיינו שמחים שמחת בית השואבה לא ראינו שינה – “When they were rejoicing by the Simchas Beis HaSho’eva, they never saw sleep”. The Gemara asks: Surely tt’s not possible to stay awake for three days without any sleep? The Gemara answers: לא טעמנו טעם שינה, דהוו מנמנמי אכתפא דהדדי – “They didn’t taste proper sleep, however, they dozed off on the shoulders of each other”.
The question is, what was the heter for them to sleep outside the succah, the halachah is (Orach Chaim 539:2), “Even temporary sleep is forbidden outside of the succah”?
The Shu”t Tashbatz (siman 100) asks this question and answers: The prohibition of sleeping outside the succah is only rabbinic in nature due to the concern that one may continue to sleep, and in such a case they never forbade it.
The Gilyonei HaShas (Succah 26) asks: This answer fits with Abaye who holds that temporary sleep is only an issur derabonon, according to Rava however, the issur is de’O’raisa, as: דאין קבע לשינה ופעמים די במשהו שינה – “There is no fixed amount of sleep, and sometimes a little bit is enough”, and when there is a machlokes between Abaye and Rava we go like Rava. Therefore, the prohibition of sleeping outside the succah is de’O’raisa, so our original question returns?
Additionally, even if the issur is only derabonon, why does that help? Perhaps the answer is that אין שבות במקדש, there are no issurei derabonon in the Beis HaMikdosh. However, this also doesn’t help as the Meiri (Yoma 69), Maharatz Chiyos and other says that the logic of אין שבות במקדש doesn’t apply when it comes to sleeping, as the reason of אין שבות במקדש is because Kohanim are zerizin [meticulous], when they are sleeping, however, we can’t say this.
R’ Tzvi Pesach Frank (Mikra’ei Kodesh, Succah, Vol. 1, siman 33) answers: Although temporary sleep (shinas arai) is a problem, dozing off is ok, and he cites proof from the aforementioned Gemara. How were they allowed to fall asleep on each other’s shoulders? It must be they dozed off, and dozing off is allowed. (This would be a big limud zechus for all those who doze off during various droshas given over Succos).
R' Tzvi Pesach brings the Mishnah Berurah (639:11) who quotes the Pri Megodim who writes on the Mechaber which says, “One shouldn’t sleep outside the succah even a temporary sleep”, that sometimes a temporary sleep is enough and is considered “fixed”, see siman 44 where it’s clear the amount is the time it takes to walk 100 amos. However, less than that isn’t even temporary, and perhaps the same is with succah. Perhaps in the Beis HaMikdosh they dozed off for an amount of time less than what it takes to walk 100 amos, therefore, it was ok.
However, the Sefas Emes (Succah 26a) is in doubt, if a sleep shorter than the amount of time it takes to walk 100 amos is allowed outside the succah.
However, the Bikuray Ya’akov (639:12) writes that although in siman 44 the temporary shiur is the time it takes to walk 100 amos in regard to succah, even less than this is forbidden.
A different answer we can suggest is that they fell asleep b’oinus [by mistake] and אונס רחמנא פטריה, the Torah doesn’t hold one accountable for oinus. If, however, they would purposely fall asleep, than it would in fact be a problem. (This may be another limud zechus for those who fall asleep during droshas on Succos)
Finally, R’ Zilberstein in Chasukei Chemed (Succah 53a) suggests, that at the Simchas Beis HaSho’eva there was kabbolas Pnei Shechinah [greeting of the Shechinah], and if one is exempt from succah when visiting a rebbe, then certainly when visiting the Shechinah one is exempt. (The above all comes from Madanay Asher)