-
Notifications
You must be signed in to change notification settings - Fork 227
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
Upgrade an app to Node 18 breaks APM with the default configuration #3045
Comments
For the record, simply configuring the agent to connect to |
Reference to the change in NodeJS: nodejs/node#39987 |
…7.0.0.1' rather than 'localhost' Starting in node v17 the defaults for DNS resolution order was changed (nodejs/node#39987) such that `dns.lookup()` no longer sorted IPv4 addresses first. This impacts usage of the *default* APM Server URL (the `serverUrl` config var), 'http://localhost:8200', when using node >=17 because the APM server only binds to the IPv4 address by default (elastic/apm-server#1405). Fixes: #3045
Agreed on changing the default as you suggest. Thanks for this issue, @ddolcimascolo! I actually ran into the same basic issue earlier when adding support for Node v17 here: #2380 (comment) However, I hadn't made the logical leap that this would break usage of the APM agents usage of 'localhost' for the I still have some changes to add to my PR. I likely won't get a release out for about a week. |
Side note: Recently supported Lambda Node v18 containers not currently affected. With this handler code: dns.lookup('localhost', {all: true}, (err, results) => {
console.log('XXX dns.lookup(localhost) results:', results)
}) the result is:
I.e. the IPv4 "localhost" result is first. I.e. the system resolver is returning the IPv4 address first. |
…6 ambiguity The current default APM server URL -- 'http://localhost:8200' -- is ambiguous. "localhost" can resolve to a '127.0.0.1' (IPv4) or '[::1]' (IPv6). At least in Node v17 the default `dns.lookup()` ordering of results was changed to no longer explicitly sort IPv4 addresses first. That means that on systems where the default resolver returns '[::1]' first for "localhost" will result in a broken attempt to talk to a default-configured local APM server: elastic/apm-agent-nodejs#3045 This is because APM server only binds to the IPv4 port: elastic/apm-server#1405
Thx for fixing @trentm! |
…7.0.0.1' rather than 'localhost' (#3049) Starting in node v17 the defaults for DNS resolution order was changed (nodejs/node#39987) such that `dns.lookup()` no longer sorted IPv4 addresses first. This impacts usage of the *default* APM Server URL (the `serverUrl` config var), 'http://localhost:8200', when using node >=17 because the APM server only binds to the IPv4 address by default (elastic/apm-server#1405). Fixes: #3045 Refs: elastic/apm#727
…6 ambiguity (#727) The current default APM server URL -- 'http://localhost:8200' -- is ambiguous. "localhost" can resolve to a '127.0.0.1' (IPv4) or '[::1]' (IPv6). At least in Node v17 the default `dns.lookup()` ordering of results was changed to no longer explicitly sort IPv4 addresses first. That means that on systems where the default resolver returns '[::1]' first for "localhost" will result in a broken attempt to talk to a default-configured local APM server: elastic/apm-agent-nodejs#3045 This is because APM server only binds to the IPv4 port: elastic/apm-server#1405
…7.0.0.1' rather than 'localhost' (elastic#3049) Starting in node v17 the defaults for DNS resolution order was changed (nodejs/node#39987) such that `dns.lookup()` no longer sorted IPv4 addresses first. This impacts usage of the *default* APM Server URL (the `serverUrl` config var), 'http://localhost:8200', when using node >=17 because the APM server only binds to the IPv4 address by default (elastic/apm-server#1405). Fixes: elastic#3045 Refs: elastic/apm#727
Describe the bug
Under Node 18, on a system with ipv6 enabled,
localhost
resolves to::1
(the ipv6 address) while under Node <= 16 it resolved to127.0.0.1
(the ipv4 address). Considering that APM server listens on the ipv4 address only in these conditions if using the default configuration (as per elastic/apm-server#1405), upgrading an application using this agent from Node 16 to Node 18 (now that Node 18 is LTS) will prevent APM from working because the agent defaultsserverUrl
tohttp://localhost:8200
.To Reproduce
Upgrade an existing app using this agent to Node 18.
Expected behavior
APM keeps on working fine after the Node upgrade.
Environment (please complete the following information)
How are you starting the agent? (please tick one of the boxes)
agent.start()
directly (e.g.require('elastic-apm-node').start(...)
)elastic-apm-node/start
from within the source code-r elastic-apm-node/start
Additional context
Suggested fix: Default
serverUrl
tohttp://127.0.0.1:8200
The text was updated successfully, but these errors were encountered: