in lib/cmds/start.ts [349:380]
function waitFor(
getStatus: () => Promise<string>, testStatus: (status: string) => boolean, desc?: string) {
const checkInterval = 100;
return new Promise<void>((resolve, reject) => {
let waited = 0;
(function recursiveCheck() {
setTimeout(() => {
getStatus()
.then<void>((status: string) => {
if (!testStatus(status)) {
return Promise.reject(
'Invalid status' + (desc ? ' for ' + desc : '') + ': ' + status);
}
})
.then(
() => {
resolve();
},
(error: any) => {
waited += checkInterval;
if (waited < maxWait) {
recursiveCheck();
} else {
reject(
'Timed out' + (desc ? ' wating for' + desc : '') +
'. Final rejection reason: ' + JSON.stringify(error));
}
});
}, checkInterval);
})();
});
};