in templates/nodejs/src/video-uploader.js [426:456]
static async waitUntilReady(
api: FacebookAdsApi,
videoId: number,
interval: number,
timeout: number,
) {
const startTime = new Date().getTime();
let status = null;
while (true) {
status = VideoEncodingStatusChecker.getStatus(api, videoId);
status = status['video_status'];
if (status !== 'processing') {
break;
}
if (startTime + timeout <= new Date().getTime()) {
throw Error(`Video encoding timeout: ${timeout}`);
}
await sleep(interval);
}
if (status !== 'ready') {
status = status == null ? '' : status;
throw Error(`Video encoding status ${status}`);
}
return;
}