A daughter of the Messenger of Allah ﷺ sent for him while I was with him, along with Saad and, I believe, Ubayy. She sent word that her son or daughter was dying and asked him to come to them. He sent back his greetings of peace and said, "Tell her that to Allah belongs what He takes and what He gives, and everything with Him has an appointed term. So let her be patient and seek reward."She sent for him again, urging him by oath to come. So he went to her, and the child was placed in the lap of the Messenger of Allah ﷺ, with his breath rattling in his chest. The eyes of the Messenger of Allah ﷺ overflowed with tears.Saad said to him, "What is this?"He replied, "This is mercy that Allah has placed in the hearts of whomever He wills. Allah shows mercy only to those of His servants who are merciful."
حدثنا أبو الوليد الطيالسي حدثنا شعبة عن عاصم الأحول قال سمعت أبا عثمان
أن ابنة لرسول الله ﷺ أرسلت إليه وأنا معه وسعد وأحسب أبيا أن ابني أو بنتي قد حضر فاشهدنا فأرسل يقرئ السلام فقال قل لله ما أخذ وما أعطى وكل شيء عنده إلى أجل فأرسلت تقسم عليه فأتاها فوضع الصبي في حجر رسول الله ﷺ ونفسه تقعقع ففاضت عينا رسول الله ﷺ فقال له سعد ما هذا قال إنها رحمة وضعها الله في قلوب من يشاء وإنما يرحم الله من عباده الرحماء
Bukhari narrated it in Kitab al-Janaiz, in the chapter titled "The saying of the Prophet ﷺ, 'The deceased is punished for some of the weeping of his family over him,'" hadith no. 1284, and Muslim narrated it in Kitab al-Janaiz, in the chapter on weeping over the deceased, hadith no. 923, from the hadith of Aasim al-Ahwal, with the same chain.