- Node.js 0.10.26
- OS X 10.9.2 (also on ubuntu vagrant box)
In two different modules on my system, when I run tests using mocha, I get this error:
{ [Error: getaddrinfo ENOTFOUND] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }
Which would normally mean I tried to resolve a nonexistent host. I attempted to spot the problem using dtrace with this script (that I found and slightly modified):
#!/usr/sbin/dtrace -s
#pragma D option quiet
dtrace:::BEGIN
{
printf("%-20s %-12s %s\n", "TIME", "LATENCY(ms)", "HOST");
}
pid$target::getaddrinfo:entry
{
self->host = copyinstr(arg0);
self->start = timestamp;
}
pid$target::getaddrinfo:return
/self->start/
{
printf("%d", arg1);
this->delta = (timestamp - self->start) / 1000000;
printf("%-20Y %-12d %s\n", walltimestamp, this->delta, self->host);
self->host = 0;
self->start = 0;
}
Using this I can see that every host that gets hit by my tests is either in my host file or is my hostname. The printf("%d", arg1);
prints out (I think) the return value of the function. Unfortunately the return value I see is some big number and not 0
or -1
like it should be.
So there is probably something wrong with my dtrace script, but that does not explain my bigger problem:
Why is the host data-proxy
not resolved when my hosts file contains 127.0.0.1 data-proxy
? and why does this only happen to me when I am running tests with mocha and not when I run my services and hit them manually?
If you want to see the relevant node.js code that gets the errors, feel free to examine mongodb and request because my usage looks like their examples.