a situation in which you are successful, but which could also have ended badly
a situation in which you are successful, but which could also have ended badly
Phew! That was a near thing! It could have been a disaster.
Definitions from the Oxford Advanced Learner's Dictionary, 9th edition