We went out with the Prophet ﷺ, and when he reached al-Baqi he came upon a fresh grave. He asked about it, and they said, "It is so-and-so." He recognized her and said, "Why did you not inform me of her?"They said, "You were taking your midday rest and fasting, so we disliked disturbing you."He said, "Do not do that. I must not learn that any of you has died while I am among you without your informing me of it, for my prayer over him is a mercy for him." Then he came to the grave, and we formed rows behind him, and he pronounced four takbirs over her.
حدثنا أبو بكر بن أبي شيبة حدثنا هشيم حدثنا عثمان بن حكيم حدثنا خارجة بن زيد بن ثابت عن يزيد بن ثابت وكان أكبر من
خرجنا مع النبي ﷺ فلما ورد البقيع فإذا هو بقبر جديد فسأل عنه قالوا فلانة قال فعرفها وقال ألا آذنتموني بها قالوا كنت قائلا صائما فكرهنا أن نؤذيك قال فلا تفعلوا لا أعرفن ما مات منكم ميت ما كنت بين أظهركم إلا آذنتموني به فإن صلاتي عليه له رحمة ثم أتى القبر فصففنا خلفه فكبر عليه أربعا
[Its chain of transmission is sahih] Nasai reported it, 4/84-85, Book of Funerals, Chapter on the Prayer over the Grave, hadith no. 2024, from the hadith of Uthman bin Hakeem Abu Sahl, through him, and Ibn Hibban graded it sahih (Mawarid), hadith nos. 759, 761.