Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
tirmidhi:2483ʿAlī b. Ḥujr > Sharīk > Abū Isḥāq > Ḥārithah b. Muḍarrib > Ataynā Khabbāb Naʿūduh And Qad Āktawá Sabʿ Kayyāt > Laqad Taṭāwal Maraḍī Walawlā Annī

"We went to visit Khabbab who had himself cauterized in seven places on his body. He said: 'I have been ill for so long, and if it was not that I heard the Messenger of Allah ﷺ saying: "None of you should wish for death" then I would have wished for it, and he said: "A man is rewarded for [all of] his spending except for the dust" - or he said - "in the building."  

Abū ʿĪsá said that this Ḥadīth is Ḥasan-Ṣaḥīḥ.
الترمذي:٢٤٨٣حَدَّثَنَا عَلِيُّ بْنُ حُجْرٍ أَخْبَرَنَا شَرِيكٌ عَنْ أَبِي إِسْحَاقَ عَنْ حَارِثَةَ بْنِ مُضَرِّبٍ قَالَ

أَتَيْنَا خَبَّابًا نَعُودُهُ وَقَدِ اكْتَوَى سَبْعَ كَيَّاتٍ فَقَالَ لَقَدْ تَطَاوَلَ مَرَضِي وَلَوْلاَ أَنِّي سَمِعْتُ رَسُولَ اللَّهِ ﷺ يَقُولُ لاَ تَمَنَّوُا الْمَوْتَ لَتَمَنَّيْتُ وَقَالَ يُؤْجَرُ الرَّجُلُ فِي نَفَقَتِهِ كُلِّهَا إِلاَّ التُّرَابَ أَوْ قَالَ فِي الْبِنَاءِ  

قَالَ أَبُو عِيسَى هَذَا حَدِيثٌ حَسَنٌ صَحِيحٌ

See similar narrations below:

Collected by Ibn Mājah, Ṭabarānī
ibnmajah:4163Ismāʿīl b. Mūsá > Sharīk > Abū Isḥāq > Ḥārithah b. Muḍarrib > Ataynā Khabbāb Naʿūduh > Laqad Ṭāl Suqmī And Lawlā Annī

“We came to Khabbab to visit him (when he was sick), and he said: ‘I have been sick for a long time, and were it not that I heard the Messenger of Allah ﷺ say: “Do not wish for death,” I would have wished for it.’ And he said: “A person will be rewarded for all his spending, except for (what he spends) on dust,” or he said, “on building.”  

ابن ماجة:٤١٦٣حَدَّثَنَا إِسْمَاعِيلُ بْنُ مُوسَى حَدَّثَنَا شَرِيكٌ عَنْ أَبِي إِسْحَاقَ عَنْ حَارِثَةَ بْنِ مُضَرِّبٍ قَالَ أَتَيْنَا خَبَّابًا نَعُودُهُ فَقَالَ لَقَدْ طَالَ سُقْمِي وَلَوْلاَ أَنِّي

سَمِعْتُ رَسُولَ اللَّهِ ﷺ يَقُولُ لاَ تَتَمَنَّوُا الْمَوْتَ لَتَمَنَّيْتُهُ وَقَالَ إِنَّ الْعَبْدَ لَيُؤْجَرُ فِي نَفَقَتِهِ كُلِّهَا إِلاَّ فِي التُّرَابِ أَوْ قَالَ فِي الْبِنَاءِ  

tabarani:3670[Chain 1] al-Ḥaḍramī > Ibn Āb.ah al-Suddī [Chain 2] ʿAlī b. ʿAbd al-ʿAzīz > Ibn al-Aṣbahānī > Sharīk > Abū Isḥāq > Ḥārithah

[Machine] We entered upon a blacksmith whom we used to visit, and he was suffering from seven parasites in his stomach. He said, "If I had not heard the Messenger of Allah ﷺ saying, 'Do not wish for death,' I would have wished for it."  

الطبراني:٣٦٧٠حَدَّثَنَا الْحَضْرَمِيُّ ثنا ابْنُ ابْنَةَ السُّدِّيُّ ح وَحَدَّثَنَا عَلِيُّ بْنُ عَبْدِ الْعَزِيزِ ثنا ابْنُ الْأَصْبَهَانِيِّ قَالَا ثنا شَرِيكٌ عَنْ أَبِي إِسْحَاقَ عَنْ حَارِثَةَ قَالَ

دَخَلْنَا عَلَى خَبَّابٍ نَعُودُهُ وَقَدِ اكْتَوَى سَبْعَ كَيَّاتٍ فِي بَطْنِهِ فَقَالَ لَوْلَا أَنِّي سَمِعْتُ رَسُولَ اللهِ ﷺ يَقُولُ «لَا تَمَنَّوُا الْمَوْتَ لَتَمَنَّيْتُهُ»