It was reported from the Messenger of Allah ﷺ, and he mentioned several hadiths, among them that the Messenger of Allah ﷺ said, "How excellent it is for a slave to die while excelling in the worship of Allah and in serving his master well. How excellent it is for him."
و حدثنا محمد بن رافع حدثنا عبد الرزاق حدثنا معمر عن همام بن منبه قال هذا ما
عن رسول الله ﷺ فذكر أحاديث منها وقال قال رسول الله ﷺ نعما للمملوك أن يتوفى يحسن عبادة الله وصحابة سيده نعما له