Do you remember in Luke 22:31-32, when Peter over-confidently said to Christ, "I'm willing to go to the death for You!" Jesus said, "Well you know Peter, Satan has desired to sift you, but I've prayed for you that when that occurs that your faith not fail." Do you think God was not going to respond to that? Certainly He did.
Jesus said, "When you're converted, when you come to yourself after this occurs"—He knew what was going to happen to Peter, to all of them. Their faith was going to fail and they weren't going to be loyal to Him. They all ran and God responded to that prayer.
The word fail, incidentally, does not mean "give out wholly or completely." Peter's faith did not give out completely even though he failed to remain loyal to Christ. He rebounded because God was there with him.