Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(Downloaders): tolerate DNS lookup timeout and use caches
Browse files Browse the repository at this point in the history
  • Loading branch information
evshiron committed Aug 21, 2017
1 parent bf3e44b commit 434aea4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/Downloader.ts
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions src/lib/FFmpegDownloader.ts
Expand Up @@ -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);
Expand Down

0 comments on commit 434aea4

Please sign in to comment.