A man passed away whom the Messenger of Allah ﷺ had been visiting during his illness. They buried him at night, and when morning came they informed the Prophet ﷺ of his death.He asked, "What kept you from informing me?"They replied, "It was night and very dark, and we did not want to trouble you."So he went to the grave and prayed over him.
حدثنا علي بن محمد حدثنا أبو معاوية عن أبي إسحق الشيباني عن الشعبي
مات رجل وكان رسول الله ﷺ يعوده فدفنوه بالليل فلما أصبح أعلموه فقال ما منعكم أن تعلموني قالوا كان الليل وكانت الظلمة فكرهنا أن نشق عليك فأتى قبره فصلى عليه
Bukhari narrated it in the Book of Funerals, Chapter on Announcing a Funeral, hadith no. 1247, from the hadith of Abu Muawiya. Muslim also narrated it in the Book of Funerals, Chapter on Prayer at the Grave, hadith no. 954, from the hadith of Shaybani, with the same wording.