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

Error when running karma without internet connection #2050

Closed
RobertDiebels opened this issue Apr 13, 2016 · 14 comments
Closed

Error when running karma without internet connection #2050

RobertDiebels opened this issue Apr 13, 2016 · 14 comments
Labels

Comments

@RobertDiebels
Copy link

RobertDiebels commented Apr 13, 2016

Expected behavior

I would expect to be able to run unittests even when I do not have an internet connection available.
My internet provider decided to ditch my connection today, I was working from home and I thought well, while they fix this I'll go write some more unittests.
No go. Apparently something goes wrong when it tries to lookup address information (which is not available).

Actual behavior

I get the following error:

C:\Users\project_name\node_modules\karma\lib\runner.js:65
      throw e
      ^

Error: getaddrinfo ENOENT localhost:9877
    at Object.exports._errnoException (util.js:849:11)
    at errnoException (dns.js:31:15)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)

Enviroment Details

  • Karma version (output of karma --version): 0.13.22 (reproducible on 1.3.0)
  • Relevant part of your karma.config.js file: None
  • Other info:
  • Running Windows 10.
  • Running this in Webstorm 11 (though it also happens running CLI commands).

See: https://github.com/RobertDiebels/karma-test/tree/master for further details.

Steps to reproduce the behaviour

  1. Disconnect from all your networks.
  2. run command karma start
  3. run command karma run --conf karma.conf.js --file jasmine-test.spec.js
  4. Behold the error message

This is reproducible on Karma version: 1.3.0 just ran the steps above again.

@RobertDiebels
Copy link
Author

RobertDiebels commented May 7, 2016

@dignifiedquire Is there anything I need to provide to speed up the investigation?

@RobertDiebels
Copy link
Author

Any chance on this getting picked up?

@maksimr
Copy link
Contributor

maksimr commented Dec 17, 2016

@RobertDiebels is it reproduced on latest version of karma?

Thanks

@maksimr
Copy link
Contributor

maksimr commented Dec 17, 2016

Which command do you run in terminal to start karma?

@RobertDiebels
Copy link
Author

@maksimr I've created a repo for reproduction purposes https://github.com/RobertDiebels/karma-test/tree/master . I'll update my initial description with version numbers and the like.

@RobertDiebels
Copy link
Author

RobertDiebels commented Dec 17, 2016

@maksimr just updated the description and checked if I get the same on 1.3.0. I think it's caused by running in the browser? Shutting off the network adapter disables the websockets I think, I haven't looked at the code.

Still the thing with unit tests is that they should be able to run with or without a functioning or connected network adapter.

@maksimr
Copy link
Contributor

maksimr commented Dec 17, 2016

@RobertDiebels Thanks!

I totally agree that karma should work without internet connection (offline).

I have tested on MacOs all work as expected if disable network(ifconfig en0 down), I don't understand what meant shut off your adapter and I don't know how it works on Windows

but be carefully karma based on network client-server architecture and if you totally remove network adapter so that local network also does not work karma will not work and this is expected behaviour.

@RobertDiebels
Copy link
Author

RobertDiebels commented Dec 18, 2016

@maksimr yea the part about the adapter makes sense.

I think I first encountered this when my connection dropped for an hour or two when I was working from home. So I tried reproducing by just shutting off the adapter (not the same ofc. I just didn't feel like crawling under my desk xD).

I'll try to simulate by disconnecting my LAN cable or turning off my router.

EDIT:
Just reproduced this by unplugging my LAN cable. Same steps as before only instead of shutting off the adapter I removed the cable.

EDIT2:
Changed the description and removed the adapter part.

@maksimr
Copy link
Contributor

maksimr commented Dec 18, 2016

@RobertDiebels thanks, very strange I will try check it on windows 10

@maksimr
Copy link
Contributor

maksimr commented Dec 18, 2016

I can confirm that problem exist, but problem in karma run command only

karma start work as expected, karma run does not work if disable network

karma-windows-problem

@maksimr
Copy link
Contributor

maksimr commented Dec 18, 2016

@RobertDiebels how workaround you cuold set hostname: '127.0.0.1' in karma.config.js

@maksimr
Copy link
Contributor

maksimr commented Dec 18, 2016

I have investigated the problem and the problem in nodejs iteself - nodejs/node-v0.x-archive#25489

I don't think that add workaround to runner.js is best solution because it could break ipv6.
So my suggest add this problem with workaround to FAQ.

cc @dignifiedquire

@RobertDiebels
Copy link
Author

@maksimr thanks for the investigation. Will use the work-around.

@yaacovCR
Copy link

Consider node-offline-localhost.

Add the following before the breaking code:

require('node-offline-localhost').always();

And it just works (hopefully), at least until RFC 3493 gets fixed.

Full disclosure: I authored this package to streamline https in my dev environment when offline.

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

No branches or pull requests

4 participants