oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.71k stars 2.72k forks source link

Bun `dns.resolve6` returns IPv4-mapped IPv6 address on macOS but IPv6 address on Linux #13003

Open adam12 opened 2 months ago

adam12 commented 2 months ago

What version of Bun is running?

1.1.22-debug+e585f900c

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

$ bun repl
> require('dns').resolve6('example.com', console.log)
> null ::ffff:93.184.215.14 6

What is the expected behavior?

$ bun repl
> require('dns').resolve6('example.com', console.log)
> null 2606:2800:21f:cb07:6820:80da:af6b:8b2c 6

What do you see instead?

No response

Additional information

Nodejs appears to return the correct result on macOS.

$ node
> require('dns').resolve6('example.com', console.log)
QueryReqWrap {
  bindingName: 'queryAaaa',
  callback: [Function: log],
  hostname: 'example.com',
  oncomplete: [Function: onresolve],
  ttl: false
}
> null [ '2606:2800:21f:cb07:6820:80da:af6b:8b2c' ]

Switching to c-ares backend and using dns.lookup directly seems to be correct.

$ bun repl
> dns.lookup('example.com', {family: 6, backend: 'c-ares'}, console.log)
> null 2606:2800:21f:cb07:6820:80da:af6b:8b2c 6
RiskyMH commented 1 day ago

@adam12 are you still running into this discrepancy?

adam12 commented 18 hours ago

Still observed, using 1.1.31.

RiskyMH commented 13 hours ago

Thanks for sharing! That’s really interesting—I’m not sure why this is happening. I've checked with a few others using macOS, and they’ve observed the correct behavior, so there might be something unusual going on with Bun in this case.