question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugging connectivity issues | reqError === undefined

See original GitHub issue

I’m trying to set up autocannon and think I’m having some connectivity issues. Running against a local instance works fine. However if I target the remote machine I want to test, all requests seem to error. I suspect issues with proxy or broken SSL chains.

I couldn’t figure out how to debug the request errors though. Is there a way to print each requests response/error message? It would help a lot to narrow down the problem.

const inst = autocannon({
  url: 'http://localhost:5010/api/v1/endpoint',
  connections: 10,
  pipelining: 20,
  duration: 10,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: payload
}, (err, res) => {
    console.error(err);
    console.log(res);
});

let cnt = 0;
inst.on('reqError', e => console.log(`Request error (${cnt++}): ${e}`));

What happens is that I see a lot of those Request error logs but apparently there is no argument passed to it, so e===undefined

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
GlenTikicommented, Feb 18, 2017

Also, for other purposes:

You can access the events the internal http client emits, using the setupClient property of the options. Check here: https://github.com/mcollina/autocannon#client-events (The internal error events aren’t documented, that might be worth a PR)

You can use this to see if the errors are timeouts or connection errors, and if they’re connection errors, get access to the error object passed to the socket that created it. Here’s the snippet you need:

const inst = autocannon({
  url: 'http://localhost:5010/api/v1/endpoint',
  connections: 10,
  pipelining: 20,
  duration: 10,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: payload
   setupClient: setupClientEventHandlers
}, (err, res) => {
    console.error(err);
    console.log(res);
});

let cnt = 0;
inst.on('reqError', e => console.log(`Request error (${cnt++}): ${e}`));

function setupClientEventHandlers (client) {
   client.on('connError', (error) => console.log('connection error', error))
   client.on('timeout', (error) => console.log('timeout'))
}
0reactions
anoffcommented, Feb 21, 2017

I understand that benchmarking through a proxy does not make sense. However I also don’t want to deploy to the designated test runtime to set the thing up. I was planning on running it with non-benchmark parameters. But I’ll just have to stub the autocannon behavior for development then.

Feel free to close the issue, I’ll try to PR updated docs with the hints that @thekemkid gave me earlier for future reference. Or if you have any ideas how the error should be propagated I could try to do a code-PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Node debug - undefined error - Stack Overflow
Well it seems to be a problem with the node V0.13.0-pre , I am using on Linux. I tried same code on Windows...
Read more >
Resolve Error "$ is undefined" - Cornell University
Use the troubleshooting steps below to resolve the browser Script Error that ... Disable script debugging (Internet Explorer) is checked.
Read more >
Fix JavaScript errors that are reported in the Console
In this article. Fix JavaScript errors; Find and debug network issues; Create errors and traces in the Console; See also.
Read more >
"Internet Explorer Script Error ... error has occurred on ... - IBM
Resolving The Problem · 1. Launch Microsoft Internet Explorer · 2. Click "Tools - Internet Options" · 3. Click "Advanced" · 4. Scroll...
Read more >
express return error
Trouble installing or updating your Adobe app? ... Debugging the network I can clearly see Express returned status 200 with the correct json...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found