The Prophet ﷺ would sometimes find that dawn arrived while he was in a state of major ritual impurity, so he would bathe and fast.
حدثنا سفيان عن سمي عن أبي بكر بن عبد الرحمن
أن النبي ﷺ كان يدركه الصبح وهو جنب فيغتسل ويصوم
Its isnad is sahih. It was mentioned previously at 23944.