We consider a φ Josephson junction, which has a bistable zero-voltage state with the stationary phases ψ=±φ. In the nonzero voltage state the phase "moves" viscously along a tilted periodic double-well potential. When the tilting is reduced quasistatically, the phase is retrapped in one of the potential wells. We study the viscous phase dynamics to determine in which well (-φ or +φ) the phase is retrapped for a given damping, when the junction returns from the finite-voltage state back to the zero-voltage state. In the limit of low damping, the φ Josephson junction exhibits a butterfly effect - extreme sensitivity of the destination well on damping. This leads to an impossibility to predict the destination well.