-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Node 10.8.0 does not support lookup
on Agent
#27695
Comments
Fishrock123
added
dns
Issues and PRs related to the dns subsystem.
http
Issues or PRs related to the http subsystem.
labels
May 14, 2019
Custom lookup() DOES WORK as expected for me
Sample snippet const http = require('http');
const agent = process.argv[2] === '--agent' ? new http.Agent({
lookup: (hostname, opts, cb) => {
cb && cb(new Error('unresolved hostname'), null, null);
}
}) : null;
const requestOptions = {
hostname: 'google.com',
agent,
}
const req = http.request(requestOptions, (res) => {
res.on('data', () => { });
res.on('end', () => { console.log('request fulfilled'); });
}).end();
req.on('error', (e) => {
console.error(`request error: ${e.message}`);
}); Results
|
My issue was with using the global agent. I should have specified that.
|
@firasdib |
@ktrongnhan I simply replaced the global agent like this: const http = require('http');
http.globalAgent = new http.Agent({ lookup: customFunction }); |
Closing, should be fixed by #25170. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The docs state you can specify your own
lookup
function for DNS resolution when creating anAgent
. See https://nodejs.org/dist/latest-v10.x/docs/api/net.html#net_socket_connect_options_connectlistener and https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_class_http_agentHowever, this option is not respected in v10.8.0. After upgrading to v12, it worked as intended.
The text was updated successfully, but these errors were encountered: