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
ENOTFOUND, Domain name not found #52
Comments
Important to note is that the same code, but with an external host, works perfect: http = require 'http'
nock = require 'nock'
options =
host: 'www.google.be',
port: 80,
path: '/'
http.get options, (error, reply) ->
console.log error
console.log reply |
+1. I have the exact same problem, just killed an hour+ looking for it in other libraries. Happy to take a workaround... |
FYI, problem first appears in 0.10.6. I tried everything from 0.10.1 (where it used to work for me), up to 0.10.8, and it appears with 0.10.6 |
And one more for you: It only occurs when you specify a port other than 80 on the http.get. Specifying port 80 or no port works: var http = require('http'); http.get({host:"localhost"}, function(res) { http.get({host:"localhost",port:80}, function(res) { http.get({host:"localhost",port:81}, function(res) { Will give the following output: PORT81 error: getaddrinfo ENOENT It appears to have something to do with commit 8797e28 |
I got it. It is that one. And the problem is in intercept.js LL42-64 or LL 93-134. Here is what is wrong. In line 93-134 (or so), http.request is overridden. Makes sense. Then nock checks if it has interceptorsFor given the options. If it finds, it uses those, else it just launches the oldRequest. BUT: if it is anything other than a non-standard port (http:80 or https:443), it changes the original options object. So if options was the first part, it transforms to the second part {host:"localhost",port:80} -> {host:"localhost",port:80} It then finds no interceptor and passes the request on to oldRequest, but it now changed the original options. What it should do is duplicate the options, then modify those, so that the original stays. |
Thanks for the report, released nock v0.11.4 |
Speedy! Still got a different bug. Look at intercept.js L69: console.log('basePath:', basePath) I don't think you want that console.log in release... :-) |
Oops, thanks for noticing it, removed in nock v0.11.5. |
No prob. Putting in. "nock":">=0.11.5" now. On Mar 28, 2012, at 11:05 AM, Pedro Teixeira
|
Thank you pgte & deitch for working out a solution! |
Pleasure. Glad I was able to find it and proffer a solution, rather than just complain, "it doesn't work!" :-) Just tested 0.11.5 and works great. |
Yes, that type of report is great, helped a lot. The only best thing is a pull request with the fix ;) |
Ok, true, but it seemed silly to do a whole clone/fix/pull just for that. On Fri, Mar 30, 2012 at 9:22 AM, Pedro Teixeira <
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you! |
I ran into a problem while trying to use Nock in an existing node.js script that sends a request to a local node server.
I have reduced the problem to the code below. My server is running on localhost:5000.
Executing this will work:
But from the moment I require Nock, an error raises:
The text was updated successfully, but these errors were encountered: