"There was an eclipse of the sun and at the time we were with the Messenger of Allah ﷺ in Al-Madinah. He rushed out dragging his garment and prayed two rak'ahs, which he made lengthy. The end of his prayer coincided with the end of the eclipse. He praised and glorified Allah (SWT), then he said: 'The sun and the moon are two of the signs of Allah (SWT), and they do not become eclipsed for the death or birth of anyone. If you see anything of that, then pray like the last obligatory prayer you did before that.'" (Using translation from Nasāʾī 1486)
كَسَفَتِ الشَّمْسُ وَنَحْنُ إِذْ ذَاكَ مَعَ رَسُولِ اللهِ ﷺ بِالْمَدِينَةِ فَخَرَجَ فَزِعًا يَجُرُّ ثَوْبَهُ فَصَلَّى رَكْعَتَيْنِ أَطَالَهُمَا فَوَافَقَ انْصِرَافُهُ انْجِلَاءَ الشَّمْسِ فَحَمِدَ اللهَ وَأَثْنَى عَلَيْهِ ثُمَّ قَالَ «إِنَّ الشَّمْسَ وَالْقَمَرَ آيَتَانِ مِنْ آيَاتِ اللهِ وَإِنَّهُمَا لَا يَنْكَسِفَانِ لِمَوْتِ أَحَدٍ وَلَا لِحَيَاتِهِ فَإِذَا رَأَيْتُمْ مِنْ ذَلِكَ شَيْئًا فَصَلُّوا كَأَحْدَثِ صَلَاةٍ مَكْتُوبَةٍ صَلَّيْتُمُوهَا»