Hadithcore
Mishkat al-Masabih, 2361

Abu Dharr reported God’s messenger as saying, “God most high forgives His servant as long as the veil has not fallen.” He was asked what the veil meant and replied, “That a soul should die while associating partners with God.” Ahmad transmitted the three traditions and Baihaqi transmitted the last in <i>Kitab al-ba'th wan-nushur</i>.

وَعَنْ أَبِي ذَرٍّ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «إِنَّ اللَّهَ تَعَالَى لَيَغْفِرُ لِعَبْدِهِ مَا لَمْ يَقَعِ الْحِجَابُ» . قَالُوا: يَا رَسُولَ اللَّهِ وَمَا الْحِجَابُ؟ قَالَ: «أَنْ تَمُوتَ النَّفْسُ وَهِيَ مُشْرِكَةٌ» رَوَى الْأَحَادِيثَ الثَّلَاثَةَ أَحْمَدُ وَرَوَى الْبَيْهَقِيُّ الْأَخِيرَ فِي كِتَابِ الْبَعْثُ والنشور

References1 variant
In-Book Reference
Book 9, Hadith 134