node-downloader-helper icon indicating copy to clipboard operation
node-downloader-helper copied to clipboard

Bug report and a potential solution: ECONNRESET error

Open cocktailpeanut opened this issue 1 year ago • 0 comments

Been trying to debug why I'm getting ECONNRESET errors occasionally.

What I found was the following:

1 .The ECONNRESET error doesn't always result in dl.start() throwing. Often this results in the downloader retrying the request. 2. But sometimes it just halts with ECONNRESET. 3. When it halts with ECONNRESET, I've found that it doesn't even get to the redirect step (The URL i'm fetching involves a redirect).

Based on this, I've come to a conclusion that the ECONNRESET is happening at the HEAD step inside the getTotalSize(). It triggers the "error" event here: https://github.com/hgouveia/node-downloader-helper/blob/master/src/index.js#L365

Basically, I think this specific case of ECONNRESET is happening during the HEAD step and there is no handling logic to retry.

My current solution is to just retry the dl.start() multiple times until it eventually works. But I feel like this should be handled by the library, perhaps take a separate retryHead attribute that does the same thing as retry, but for the getTotalSize() request.

cocktailpeanut avatar Jan 03 '24 20:01 cocktailpeanut