-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
net.connect fails looking up localhost when offline (node-v0.x-archive/issues/25489 duplicate) #11320
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
Comments
Why do you think a domain name lookup should suceed when you are offline? If you want to your tests to work disconnected, don't rely on domain names, use addresses. |
Put another way, this is a host configuration issue. Unix systems usually add an entry for 'localhost' into |
I suspect it's because node does the lookup with the AI_ADDRCONFIG flag set. The archived issue also hints at that. On Windows, it makes 'localhost' unresolvable unless there is at least one non-local IPv4- or IPv6-capable network interface. (At least, I think that is how it works - don't quote me on it.) FWIW, Chromium unconditionally disables AI_ADDRCONFIG on Windows: https://chromium.googlesource.com/chromium/src/net/+/e80513ca05b7aae855297e09748c76686bdad9ab/dns/host_resolver_proc.cc#156 On Linux, it seems to disable it when no non-local interfaces exist: https://chromium.googlesource.com/chromium/src/net/+/e80513ca05b7aae855297e09748c76686bdad9ab/dns/host_resolver_proc.cc#184 I could be persuaded that setting AI_ADDRCONFIG is the wrong thing at least some of the time but I'm wary of changing it and finding out we broke the world. It's not something our CI will catch. |
@sam-github first of all. I didn't even want to have to create an issue regarding node. I was referred here by a developer from karma. As they stated it was an issue with node. Which is the archived one I linked. I do not want to use domain-names for my tests. I want to be able to run my tests without being connected to a network adapter. I could go back to the guys from Karma and say that this isn't an issue with Node if that's what you want. I have no idea of the underlying Karma code nor of the underlying Node code, and at the moment I have no desire to acquire that information. I just acted on the suggestions the guys from Karma and yourself gave me. Which were:
That's all. Also what you suggested concerning the host-name addresses is what they suggested as a work-around not an actual fix. |
@RobertDiebels A possible fix for karma is to make calls to |
While this (RFC 3493?) is all hashed out, my fix is to use a small package that overrides net.connect (!!!) to null the dns.ADDRCONFIG flag. Once require'ed, all packages will just work offline. I published this work-around to npm as node-offline-localhost. I am still trying to work out how to best formally test this; I need a test suite that can spin up node.js environments with network connectivity that can be manipulated intra-tests. Thoughts? My preference, btw, is to enable this only in a development environment. The package also supports detection of existing non-local network interfaces and nulling dns.ADDRCONFIG as appropriate; this can be done at start-up or call time. @bnoordhuis: A terrible idea? A terrible idea whose time has come? Comments are welcome. |
Since changing this would probably lead to a lot of new issues and there is a userland fix, should we close the issue? |
Yes, let's do that. Can reopen if necessary. |
Hi guys,
I have a bug to report which was found via a Karma issue. I don't have the details on exactly what went wrong though I got referred to: nodejs/node-v0.x-archive#25489 as being the cause of the issue.
The Karma issue I started is: karma-runner/karma#2050
I created a Repo for reproduction: https://github.com/RobertDiebels/karma-test
What happened is the following:
karma run
Steps to reproduce
karma run
(Disco inferno!)If I can or should provide some extra information please notify me and I'll gladly provide it.
The text was updated successfully, but these errors were encountered: