Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

supertest gets exception if the HTTP server is down #237

Closed
psinghsp opened this issue May 29, 2015 · 10 comments · Fixed by #260
Closed

supertest gets exception if the HTTP server is down #237

psinghsp opened this issue May 29, 2015 · 10 comments · Fixed by #260
Assignees
Labels
Milestone

Comments

@psinghsp
Copy link

We have a REST API to reboot the HTTP server and then poll for it using another REST API to come back. While calling a REST API when web server is down, supertest gets an exception. You can see at the specific line that "res" is undefined because HTTP server is down. I think this code on line 202 needs to be modified to deal with this situation.

/home/psingh/applianceUpgrade/node_modules/supertest/lib/test.js:202
if (res.status !== status) {
^
TypeError: Cannot read property 'status' of undefined
at Test.assert (/home/psingh/applianceUpgrade/node_modules/supertest/lib/test.js:202:12)

@kadishmal
Copy link

It's been a while. Why this PR isn't getting merged?

@mikelax
Copy link
Contributor

mikelax commented Aug 15, 2015

I am planning to try and get the 1.1.0 release out next week.

@tauren
Copy link

tauren commented Aug 15, 2015

I just tracked down this bug as well. We have a gulp task that starts our services and then runs functional tests. Due to a problem with our gulp task, the tests were running before the services finished starting. This was causing intermittent test failures with no clear reason for failure. Hoping this PR will expose the ECONNREFUSED error, which would have made debugging the problem much simpler.

@csvan
Copy link

csvan commented Sep 25, 2015

@mikelax I can still reproduce this error as of 1.1.0 - running tests against an offline server (or the wrong port on an active server) always results in a pass, even if explicit expects are set.

@mikelax
Copy link
Contributor

mikelax commented Sep 28, 2015

@csvan I will update the tag for this issue. It just recently got merged into master but it was not part of the 1.1.0 release. You can try to check out master and see if that works for you.
I am going to bump this to version 1.2.0 as I would consider this a breaking change from current behavior.

@mikelax mikelax modified the milestones: 1.2.0, 1.1.0 Sep 28, 2015
@aredridel
Copy link

Breaking changes should be 2.0, not 1.2.

But this seems like a bug fix, not something that's going to break actual uses. I may be wrong, but that's my gut-check.

@varunj90
Copy link

@mikelax - Do you know ETA for this fix; or know if supertest is working towards a fix?

My issue is similar to this : #298

@csvan - did you find a fix for it?

@jxm262
Copy link

jxm262 commented Mar 12, 2016

hi @mikelax sorry to chime in with the others, but it's also occurring on 1.2. Just did a fresh install from npm (1.2) and have the same non-descriptive error message. The other issue, is that all the tests pass. Tried running from master and get the same message as well.

Any ideas or help needed?

There's another ticket open for the same issue - #314

@RichardJECooke
Copy link

RichardJECooke commented May 26, 2016

Is there a workaround for this bug? All I get is the line [TypeError: Cannot read property 'status' of undefined], no stack trace, nothing usable to fix it.

Unlike the author of this thread, my server is definitely running. My code is:

tape(testeeName + 'creates new user in database', function (assert) {
    supertest('http:0.0.0.0:3000/')
        .post(testData.apiPrefix + "signup")
        .send(testData.validUser)
        .expect(200)
        .expect('Content-Type', /json/)
        .end(function (error, result) {
              assert.end();
    });

@timendez
Copy link

timendez commented Oct 6, 2017

I am also still getting this issue. Tried a few node versions within 6, 7, and 8. For me it happens only when I attach two files to my supertest POST request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants