node-downloader-helper: Crashing instead of catching errors.

Hello, When I attempt to download a file that doesn’t exist I get the error Error: Response status was 404 \n at ClientRequest.<anonymous> and then the project crashes. I have the dl.on(“error”,) code. But it doesn’t seem to be doing anything.

dl.on("error", (error) => {}); 

I’m not sure if I’m doing something wrong.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 23 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Yeah, the command doesn’t really work…

You need to clone the repo (git clone https://github.com/hgouveia/node-downloader-helper) into your node_modules folder, and then inside checkout the dev branch, run npm i and finally npm run build. Then it should work 😃

With v1.0.19 and dl.start().catch( err => {} ); it works now. Thanks !

My piece of code :

const dl = new DownloaderHelper(`https://docs.google.com/spreadsheets/d/${docId}/export?format=xlsx`, folderToDl);
return new Promise((resolve, reject) => {

    dl.on("end", (info: DownloadEndedStats) => {
      ....
    });

    dl.on("error", (e: ErrorStats) => {
      this.log.error(`Fail to load spreadsheet`, e);
      reject(e);
    });

    dl.start().catch((e) => reject(e) );

});

@DucksDont this sounds like a bug, i will check it this week, thanks for the report