You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Darwin <REDACTED> 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64
Subsystem
http
What steps will reproduce the bug?
Note: This bug should ideally be Node.js version and platform independent.
To reproduce, run the following code:
Code
// test-node-http-ipv6.mjsimport{request}from"http";import{lookup}from"dns";import{promisify}from"util";constlookupPromise=promisify(lookup);// Get IPv6 address of example.comconst{ address }=awaitlookupPromise("example.com",6);// Create URL from IPv6 address using square brackets.const{ protocol, host, port }=newURL(`http://[${address}]:80`);// Throws Error: getaddrinfo ENOTFOUND [::ffff:5db8:d822]// when host from IPv6 address is passed to request.request({ protocol, host, port }).end();// Does not throw error when square brackets are removed from host.request({ protocol,host: host.replace(/^\[(.+)\]$/,"$1"), port }).end();
Output
events.js:377 throw er; // Unhandled 'error' event ^Error: getaddrinfo ENOTFOUND [::ffff:5db8:d822] at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:69:26)Emitted 'error' event on ClientRequest instance at: at Socket.socketErrorListener (_http_client.js:475:9) at Socket.emit (events.js:400:28) at emitErrorNT (internal/streams/destroy.js:106:8) at emitErrorCloseNT (internal/streams/destroy.js:74:3) at processTicksAndRejections (internal/process/task_queues.js:82:21) { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: '[::ffff:5db8:d822]'}
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
The http.request should accept host encapsulated within square brackets.
What do you see instead?
The http.request internally calls getaddrinfo for host with square brackets, and gets ENOTFOUND error in return.
Additional information
This issue was noticed while testing IPv6 endpoints in AWS SDK for JavaScript in aws/aws-sdk-js-v3#2660
The text was updated successfully, but these errors were encountered:
trivikr
changed the title
http.request does not accept host encapsulated within square brackets
[http] request does not accept host encapsulated within square brackets
Aug 11, 2021
The host subcomponent of authority is identified by an IP literal encapsulated within square brackets, an IPv4 address in dotted-decimal form, or a registered name.
The square bracket characters ([ and ]) are not part of IPv6 address specification outlined in RFC 4291 though.
trivikr
added a commit
to trivikr/aws-sdk-js-v3
that referenced
this issue
Aug 11, 2021
Version
Platform
Subsystem
http
What steps will reproduce the bug?
Note: This bug should ideally be Node.js version and platform independent.
To reproduce, run the following code:
Code
Output
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
The
http.request
should accepthost
encapsulated within square brackets.What do you see instead?
The
http.request
internally calls getaddrinfo for host with square brackets, and gets ENOTFOUND error in return.Additional information
This issue was noticed while testing IPv6 endpoints in AWS SDK for JavaScript in aws/aws-sdk-js-v3#2660
The text was updated successfully, but these errors were encountered: