function keepTrying(otherArgs, promise) { promise = promise||new Promise(); // try doing the important thing if(success) { promise.resolve(result); } else { setTimeout(function() { keepTrying(otherArgs, promise); }, retryInterval); } }