The Messenger of Allah ﷺ said, "When a servant is following a good path of worship and then falls ill, it is said to the angel assigned to him, 'Record for him the equivalent of the deeds he used to perform when he was free of illness, until I release him or take him to Me.'"
قال رسول الله ﷺ: إن العبد إذا كان على طريقة حسنة من العبادة ثم مرض، قيل للملك الموكل به: اكتب له مثل عمله إذ كان طليقا حتى أطلقه أو أكفته إلي.
Abdul-Razzaq narrated it (20308), and from him Imam Ahmad (6895) and Ibn Abu Dunya in Al-Marad wal-Kaffarat (26), from Mamar, from Asim bin Abu Najud, from Khaythama, from Abdullah bin Amr, and he mentioned something similar. Haythami cited it in Al-Majma (2/303) and said, "Ahmad narrated it, and its isnad is sahih." I say, its isnad is hasan because of Asim bin Abu Najud, for he is hasan al-hadith.As for his statement, "I gather him," it means, I bring him close to the grave, as Baghawi said. He also said, "This is related to the statement of Allah Almighty, "Have We not made the earth a container" [Mursalat 77:25], meaning, possessed of gathering, that is, joining and collecting, it gathers them as the living upon its surface, and as the dead within its belly." Sharh al-Sunnah (5/241).