быть на волоске ( в шаге) от провала...
to be on the verge of failure
to be on the brink of failure
to escape by the skin of your teeth