Hadith 12340
١٢٣٤٠ - حدثنا حفص بن غياث عن ابن أبي ذئب عن صالح مولى التؤمة عن أبي هريرة قال: قال رسول اللَّه ﷺ: ["من صلى على جنازة في المسجد فلا (صلاة) (١) له"، قال: وكان أصحاب رسول اللَّه ﷺ] (٢) إذا تضايق بهم المكان رجعوا ولم يصلوا (٣).
It is narrated from Hazrat Abu Huraira (may Allah be pleased with him) that the Holy Prophet (peace and blessings be upon him) said: Whoever performs the funeral prayer in the mosque, his prayer is not valid. The narrator says that when the place would become crowded, the companions would return but would not perform the prayer.
Hadith 12342
١٢٣٤٢ - [حدثنا وكيع عن ابن أبي ذئب عن صالح مولى التؤمة عمن أدرك أبا بكر وعمر أنهم كانوا إذا تضايق بهم المصلى انصرفوا ولم يصلوا على الجنازة في المسجد] (١) (٢).
Hazrat Salih narrates from those individuals who witnessed the era of the two Shaykhs; they state that the companions would return when the space in the funeral area became tight, but they would not offer the funeral prayer in the mosque.