From 03e3eb9a816cec3311ec469576ee45069eaabbfe Mon Sep 17 00:00:00 2001 From: Isaac Grynsztein Date: Tue, 24 Mar 2020 19:27:48 -0400 Subject: [PATCH] Fixed bug where failed youtube-dl updates crashed the server (it should just continue uninterrupted) --- backend/app.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/app.js b/backend/app.js index efe0de6..fb24c66 100644 --- a/backend/app.js +++ b/backend/app.js @@ -667,7 +667,11 @@ async function autoUpdateYoutubeDL() { let binary_path = 'node_modules/youtube-dl/bin'; // versions different, download new update console.log('INFO: Found new update for youtube-dl. Updating binary...'); - await checkExistsWithTimeout(stored_binary_path, 10000); + try { + await checkExistsWithTimeout(stored_binary_path, 10000); + } catch(e) { + console.log(`ERROR: Failed to update youtube-dl - ${e}`); + } downloader(binary_path, function error(err, done) { 'use strict' if (err) { @@ -687,7 +691,7 @@ async function checkExistsWithTimeout(filePath, timeout) { return new Promise(function (resolve, reject) { var timer = setTimeout(function () { - watcher.close(); + if (watcher) watcher.close(); reject(new Error('File did not exists and was not created during the timeout.')); }, timeout);