There was an eclipse of the sun in the time of the Messenger of Allah ﷺ. He came out bewildered pulling his garment, and I was in his company at Medina. He prayed two rak'ahs and stood for a long time in them. He then departed and the sun became bright. He then said: There are the signs by means of which Allah, the Exalted, produces dread (in His servants). When you see anything of this nature, then pray as you are praying a fresh obligatory prayer.
كُسِفَتِ الشَّمْسُ عَلَى عَهْدِ رَسُولِ اللَّهِ ﷺ فَخَرَجَ فَزِعًا يَجُرُّ ثَوْبَهُ وَأَنَا مَعَهُ يَوْمَئِذٍ بِالْمَدِينَةِ فَصَلَّى رَكْعَتَيْنِ فَأَطَالَ فِيهِمَا الْقِيَامَ ثُمَّ انْصَرَفَ وَانْجَلَتْ فَقَالَ إِنَّمَا هَذِهِ الآيَاتُ يُخَوِّفُ اللَّهُ بِهَا فَإِذَا رَأَيْتُمُوهَا فَصَلُّوا كَأَحْدَثِ صَلاَةٍ صَلَّيْتُمُوهَا مِنَ الْمَكْتُوبَةِ