Novak Djokovic came within a few centimetres of the second default of his career as he narrowly avoided smacking a ball girl with a ball.