[server] Fix potentially infinite loop in findProjectDir