Sunan an-Nasa'i, Volume 2, Book 16, Hadith 1488 (DarusSalam)

It was narrated from Qabisah Al-Hilali: That there was an eclipse of the sun and the Prophet of Allah prayed two rak'ahs until it ended. Then he said: "The sun and the moon do not become eclipsed for the death of anyone, but they are two of His creations. Allah, the Mighty and Sublime, causes whatever He wants to happen in His creation. If Allah (SWT), the Mighty and Sublime, manifests Himself to any of His creation, it humbles itself before Him, so if either of them (solar or lunar eclipse) happens, pray until it is over or until Allah causes something to happen."

أَخْبَرَنَا مُحَمَّدُ بْنُ الْمُثَنَّى، قَالَ حَدَّثَنَا مُعَاذٌ، - وَهُوَ ابْنُ هِشَامٍ - قَالَ حَدَّثَنِي أَبِي، عَنْ قَتَادَةَ، عَنْ أَبِي قِلاَبَةَ، عَنْ قَبِيصَةَ الْهِلاَلِيِّ، أَنَّ الشَّمْسَ، انْخَسَفَتْ فَصَلَّى نَبِيُّ اللَّهِ صلى الله عليه وسلم رَكْعَتَيْنِ رَكْعَتَيْنِ حَتَّى انْجَلَتْ ثُمَّ قَالَ ‏ "‏ إِنَّ الشَّمْسَ وَالْقَمَرَ لاَ يَنْخَسِفَانِ لِمَوْتِ أَحَدٍ وَلَكِنَّهُمَا خَلْقَانِ مِنْ خَلْقِهِ وَإِنَّ اللَّهَ عَزَّ وَجَلَّ يُحْدِثُ فِي خَلْقِهِ مَا شَاءَ وَإِنَّ اللَّهَ عَزَّ وَجَلَّ إِذَا تَجَلَّى لِشَىْءٍ مِنْ خَلْقِهِ يَخْشَعُ لَهُ فَأَيُّهُمَا حَدَثَ فَصَلُّوا حَتَّى يَنْجَلِيَ أَوْ يُحْدِثَ اللَّهُ أَمْرًا ‏" ‏ ‏.‏

sunnah.com