Some errors can't be caught

Open
#347 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript, node.js
Domain
api, networking

Research direction

Start with the supplied Node.js reproduction and trace the request entry point used by needle('get', ...) through its Promise and protocol-error handling. Verify that the reported protocol-related error reaches the attached catch handler without crashing Node, using the example as the completion check.

Written by the indexing model from the issue text.

Description

Please see below code. Error produced by it is not possible to catch and it crashes node.

const http = require("http"),
  https = require("https"),
  url = require("url"),
  needle = require("needle");

const agent = {
  http: new http.Agent({ keepAlive: true }),
  https: new https.Agent({ keepAlive: true })
};

let parsedUrl = url.parse('http://img.tesco.com/Groceries/pi/722/5053990138722/IDShot_540x540.jpg');

let origin_resp = needle('get','http://img.tesco.com/Groceries/pi/722/5053990138722/IDShot_540x540.jpg',{ follow_max: 5, agent: (parsedUrl.protocol == "http:") ? agent.http : agent.https}).then(resp=>{console.log(resp)}).catch(err=>{console.error(err)});

There should be some way to catch such protocol related errors as they can be huge issue if not caught in production.

Dominant language
JavaScript
Stars
1.6k
Forks
237
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tomas/needle

All issues in tomas/needle

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.