Skip to content

Commit

Permalink
Fixed attempt to ECONNRESET at TLSWrap.onStreamRead #61
Browse files Browse the repository at this point in the history
  • Loading branch information
hgouveia committed Aug 24, 2021
1 parent 305676e commit ac8387f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export class DownloaderHelper extends EventEmitter {
// Error Handling
this.__request.on('error', this.__onError(this.__promise.resolve, this.__promise.reject));
this.__request.on('timeout', this.__onTimeout(this.__promise.resolve, this.__promise.reject));
this.__request.on('uncaughtException', this.__onError(this.__promise.resolve, this.__promise.reject, true));

this.__request.end();
}
Expand Down Expand Up @@ -531,14 +532,20 @@ export class DownloaderHelper extends EventEmitter {
*
* @param {Promise.resolve} resolve
* @param {Promise.reject} reject
* @param {boolean} abortReq
* @returns {Function}
* @memberof DownloaderHelper
*/
__onError(resolve, reject) {
__onError(resolve, reject, abortReq = false) {
return err => {
this.__pipes = [];

if (this.state === this.__states.STOPPED) {
if (abortReq) {
this.__requestAbort();
}

if (this.state === this.__states.STOPPED ||
this.state === this.__states.FAILED) {
return;
}

Expand Down

0 comments on commit ac8387f

Please sign in to comment.