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.

When server is down, the error message is not useful

See original GitHub issue

My test suit is hitting a server with a bunch of requests and then checks on responses. supertest is really good for making tests on response body and status code easy!

However, when the server is down for some reason the error message doesn’t allow to identify the source of the problem. Me and some other folks tripped over this a bunch of times 😃

var request = require('supertest');
request('localhost:6237')
  .get('/')
  .expect(200)
  .end(function(err, res) {
    if (err) throw err;
    console.log('Success', res.body);
  });

Running this given the server at localhost:6237 is down results in this stack trace:

$ node test.js
/path/to/test.js:8
    if (err) throw err;
                   ^
TypeError: Cannot read property 'status' of undefined

Is it something I can go ahead and fix or it’s intended functionality?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
parxiercommented, Jun 1, 2016

Is there any update on this one? Is it possible to merge #237 fix into latest version?

0reactions
bkeeperscommented, Nov 17, 2017

https://github.com/visionmedia/supertest/pull/446 should help reveal the underlying error here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When server is down, the error message is not useful #314
My test suit is hitting a server with a bunch of requests and then checks on responses. supertest is really good for making...
Read more >
What is the best the message "Server is not Running" or ...
The answer depends on goals of the message. If your goal is just to inform user about server status, the first message is...
Read more >
HTTP status code when the server is down?
If your server is down like in: shutdown, or service not started, you obviously can't send a custom error code. You will get...
Read more >
How To Deal With A Server Not Found Message?
The server not found error means that the server cannot be found, which is quite alarming. It's essential to have a relatively simple...
Read more >
Website down? Server down? 5 network troubleshooting tools ...
We've all been there: A website refuses to load, returning a generic “website is not available” or “URL was not found on this...
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