Skip to content

fix: use sync dns.getDefaultResultOrder instead of dns.promises - #22185

Merged
bluwy merged 1 commit into
vitejs:mainfrom
valerii-kuzivanov:fix/bun-dns-getDefaultResultOrder
Apr 7, 2026
Merged

fix: use sync dns.getDefaultResultOrder instead of dns.promises#22185
bluwy merged 1 commit into
vitejs:mainfrom
valerii-kuzivanov:fix/bun-dns-getDefaultResultOrder

Conversation

@valerii-kuzivanov

Copy link
Copy Markdown
Contributor

Summary

Fixes #22184

getLocalhostAddressIfDiffersFromDNS (introduced in #22151, commit 56ec256) calls dns.getDefaultResultOrder() — but dns is aliased from node:dns's promises namespace (import { promises as dns }), so it resolves to dns.promises.getDefaultResultOrder() at runtime.

Bun does not implement dns.promises.getDefaultResultOrder (tested on 1.3.10, 1.3.11 stable, 1.3.12 canary), causing vite build to fail since 8.0.6:

TypeError: promises.getDefaultResultOrder is not a function

getDefaultResultOrder is synchronous by nature — this PR imports it directly from node:dns (the sync/callback namespace) instead of going through dns.promises.

Change

  • Import getDefaultResultOrder from node:dns alongside the existing promises import
  • Call getDefaultResultOrder() directly instead of dns.getDefaultResultOrder()

Test plan

  • vite build under Bun 1.3.x no longer throws
  • No behavior change on Node.js — dns.getDefaultResultOrder exists on both dns and dns.promises in Node

`getDefaultResultOrder` is a synchronous function that exists on the
`dns` module but not on `dns.promises` in Bun. The current code imports
`{ promises as dns }` and calls `dns.getDefaultResultOrder()`, which
resolves to `dns.promises.getDefaultResultOrder()` at runtime — a method
Bun does not implement.

Import `getDefaultResultOrder` directly from `node:dns` (the sync
namespace) so the early-return guard works on both Node.js and Bun.

Fixes vitejs#22184
@ghost
ghost requested a review from sapphi-red April 7, 2026 14:05
@ghost
ghost merged commit 5c05b04 into vitejs:main Apr 7, 2026

ghost commented Apr 7, 2026

Copy link
Copy Markdown

Well this is still not working on deno, but I guess this is a deno issue: denoland/deno#33195

ghost commented Apr 7, 2026

Copy link
Copy Markdown

deno --version
deno 2.7.11 (stable, release, x86_64-unknown-linux-gnu)
v8 14.7.173.7-rusty
typescript 5.9.2

deno task build
Task build vite build
error: Uncaught (in promise) SyntaxError: The requested module 'node:dns' does not provide an export named 'getDefaultResultOrder' at file:///mnt/work/moldova/node_modules/.deno/vite@8.0.7/node_modules/vite/dist/node/chunks/node.js:20:10
const { createBuilder } = await import("./chunks/build.js");
^
at async CAC. (file:///mnt/work/moldova/node_modules/.deno/vite@8.0.7/node_modules/vite/dist/node/cli.js:764:28)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Couldn't load reviewers.

Assignees

Couldn't load assignees.