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

datagram socket send on 127.0.0.1 invokes dns.lookup() #35130

Closed
naseemkullah opened this issue Sep 9, 2020 · 4 comments
Closed

datagram socket send on 127.0.0.1 invokes dns.lookup() #35130

naseemkullah opened this issue Sep 9, 2020 · 4 comments
Labels
dgram Issues and PRs related to the dgram subsystem / UDP. invalid Issues and PRs that are invalid.

Comments

@naseemkullah
Copy link

What steps will reproduce the bug?

> const dgram = require('dgram');
undefined
> const server = dgram.createSocket('udp4');
undefined
> server.send('hi', 0, 2, 8125, '127.0.0.1', console.log)
undefined
> null 2

This results in a dns.lookup(), provided that an address is being passed to it, it should not have to.

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

As per https://nodejs.org/api/dgram.html#dgram_socket_send_msg_offset_length_port_address_callback

The address argument is a string. If the value of address is a host name, DNS will be used to resolve the address of the host.

Implies that if it is not a host name, DNS will not be used. I.e. I would not expect dns to be used if not a host name.

What do you see instead?

dns.lookup() being called

Additional information

I was able to observe dns trace by instrumenting with https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-dns

@bnoordhuis
Copy link
Member

There is no bug here. dns.lookup() has a fast path for IP addresses, hence there's no need for the dgram module to perform any special casing.

Closing but thanks anyway for the report.

@bnoordhuis bnoordhuis added dgram Issues and PRs related to the dgram subsystem / UDP. invalid Issues and PRs that are invalid. labels Sep 10, 2020
@naseemkullah
Copy link
Author

There is no bug here. dns.lookup() has a fast path for IP addresses, hence there's no need for the dgram module to perform any special casing.

Closing but thanks anyway for the report.

Thanks for explaining! It may be worthwhile to mention that in docs.

@bnoordhuis
Copy link
Member

You can send a documentation pull request if you want.

@naseemkullah
Copy link
Author

Okidokie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dgram Issues and PRs related to the dgram subsystem / UDP. invalid Issues and PRs that are invalid.
Projects
None yet
Development

No branches or pull requests

2 participants