A son of one of the daughters of the Messenger of Allah ﷺ was dying, so she sent for him to come to her. He sent back word saying, "To Allah belongs what He has taken, and to Him belongs what He has given. Everything with Him has an appointed term, so let her be patient and seek the reward."She sent to him again, swearing an oath that he must come. So the Messenger of Allah ﷺ got up, and I rose with him, along with Muaz bin Jabal, Ubayy bin Kaab, and Ubada bin Samit. When we entered, they handed the child to the Messenger of Allah ﷺ while his soul was rattling in his chest.I think he said it was like an old waterskin.The Messenger of Allah ﷺ wept, and Ubada bin Samit said to him, "What is this, Messenger of Allah?"He replied, "It is the mercy which Allah has placed in the children of Adam. Allah shows mercy only to those of His servants who are merciful."
حدثنا محمد بن عبد الملك بن أبي الشوارب حدثنا عبد الواحد بن زياد حدثنا عاصم الأحول عن أبي عثمان
كان ابن لبعض بنات رسول الله ﷺ يقضي فأرسلت إليه أن يأتيها فأرسل إليها أن لله ما أخذ وله ما أعطى وكل شيء عنده إلى أجل مسمى فلتصبر ولتحتسب فأرسلت إليه فأقسمت عليه فقام رسول الله ﷺ وقمت معه ومعه معاذ بن جبل وأبي بن كعب وعبادة بن الصامت فلما دخلنا ناولوا الصبي رسول الله ﷺ وروحه تقلقل في صدره قال حسبته قال كأنها شنة قال فبكى رسول الله ﷺ فقال له عبادة بن الصامت ما هذا يا رسول الله قال الرحمة التي جعلها الله في بني آدم وإنما يرحم الله من عباده الرحماء
Sourced from Bukhari, Book of Funerals, chapter titled "The saying of the Prophet ﷺ, 'The deceased is punished for some of his family's weeping over him'..." etc., hadith no. 1284 and elsewhere, and Muslim, Book of Funerals, chapter on weeping over the deceased, hadith no. 923, from the hadith of Asim, with this chain.