Zayd reported,

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.

Ibn Majah 1528

Sahih

حدثنا أبو بكر بن أبي شيبة حدثنا هشيم حدثنا عثمان بن حكيم حدثنا خارجة بن زيد بن ثابت عن يزيد بن ثابت وكان أكبر من

زيد قال

خرجنا مع النبي ﷺ فلما ورد البقيع فإذا هو بقبر جديد فسأل عنه قالوا فلانة قال فعرفها وقال ألا آذنتموني بها قالوا كنت قائلا صائما فكرهنا أن نؤذيك قال فلا تفعلوا لا أعرفن ما مات منكم ميت ما كنت بين أظهركم إلا آذنتموني به فإن صلاتي عليه له رحمة ثم أتى القبر فصففنا خلفه فكبر عليه أربعا

ابن ماجه 1528صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Funerals
Chapter
Prayer over the grave
Numbering
Darussalam 1528
Ibn Majah 1528