download icon indicating copy to clipboard operation
download copied to clipboard

Crashes on Timeout

Open turbobuilt opened this issue 4 years ago • 1 comments

How does the following code crash the program? I'm catching the error, but it still crashes. Only thing I can think is that it is doing something on a different thread?

try {
    await download(url, path, {
        filename: fileName,
        timeout: 10000,
        retries: 0
    })
} catch (err) {
    console.error("Error downloading", item.contentUrl);
    console.error(err)
    return;
}
events.js:200
      throw er; // Unhandled 'error' event
      ^

GotError [RequestError]: Request timed out
    at Timeout._onTimeout (/home/me/project/node_modules/got/index.js:433:24)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)
Emitted 'error' event on DuplexWrapper instance at:
    at Timeout._onTimeout (/home/me/project/node_modules/got/index.js:433:10)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7) {
  name: 'RequestError',
  code: 'ETIMEDOUT',
  host: 'd1u5p3l4wpay3k.cloudfront.net',
  hostname: 'd1u5p3l4wpay3k.cloudfront.net',
  method: 'GET',
  path: '/lolesports_gamepedia_en/7/7c/PaiN_Gaminglogo_square.png',
  protocol: 'https:',
  url: 'https://d1u5p3l4wpay3k.cloudfront.net/lolesports_gamepedia_en/7/7c/PaiN_Gaminglogo_square.png'
}

turbobuilt avatar Mar 12 '20 18:03 turbobuilt

I also encountered this problem, have you solved it now?

xsahxl avatar Nov 19 '21 08:11 xsahxl