Преглед на файлове

fix(Downloaders): tolerate DNS lookup timeout and use caches

evshiron преди 8 години
родител
ревизия
434aea44a0
променени са 2 файла, в които са добавени 18 реда и са изтрити 0 реда
  1. 9 0
      src/lib/Downloader.ts
  2. 9 0
      src/lib/FFmpegDownloader.ts

+ 9 - 0
src/lib/Downloader.ts

@@ -67,12 +67,21 @@ export class Downloader extends DownloaderBase {
             }
         }
         catch(err) {
+
+            debug('in fetch', 'err', err);
+
             if(err.code === 'ENOTFOUND' && this.options.useCaches) {
+                console.info('DNS lookup fails, use local caches at this time.');
+                return path;
+            }
+            else if(err.code === 'EAI_AGAIN' && this.options.useCaches) {
+                console.info('DNS lookup timeout, use local caches at this time.');
                 return path;
             }
             else {
                 throw err;
             }
+
         }
 
         await this.download(url, filename, path, showProgress);

+ 9 - 0
src/lib/FFmpegDownloader.ts

@@ -76,12 +76,21 @@ export class FFmpegDownloader extends DownloaderBase {
             }
         }
         catch(err) {
+
+            debug('in fetch', 'err', err);
+
             if(err.code === 'ENOTFOUND' && this.options.useCaches) {
+                console.info('DNS lookup fails, use local caches at this time.');
+                return path;
+            }
+            else if(err.code === 'EAI_AGAIN' && this.options.useCaches) {
+                console.info('DNS lookup timeout, use local caches at this time.');
                 return path;
             }
             else {
                 throw err;
             }
+
         }
 
         await this.download(url, filename, path, showProgress);