Description
Since Vite 8.0.6, running vite build under the Bun runtime fails with:
TypeError: promises.getDefaultResultOrder is not a function. (In 'promises.getDefaultResultOrder()', 'promises.getDefaultResultOrder' is undefined)
at getLocalhostAddressIfDiffersFromDNS (node_modules/vite/dist/node/chunks/node.js:2067:15)
at resolveHostname (node_modules/vite/dist/node/chunks/node.js:2082:31)
at resolveDevToolsConfig (node_modules/vite/dist/node/chunks/node.js:33872:34)
at resolveConfig (node_modules/vite/dist/node/chunks/node.js:34317:39)
This works fine with Vite 8.0.5 and earlier.
Root cause
Introduced by commit 56ec256 (PR #22151): "perf: early return in getLocalhostAddressIfDiffersFromDNS when DNS order is verbatim".
packages/vite/src/node/utils.ts imports:
import { promises as dns } from 'node:dns'
The new early-return guard added by that PR calls:
if (dns.getDefaultResultOrder() === 'verbatim') {
Because dns is aliased from dns.promises, this resolves at runtime to dns.promises.getDefaultResultOrder().
Bun implements dns.getDefaultResultOrder (sync) but not dns.promises.getDefaultResultOrder. Tested on Bun 1.3.11 (latest stable) and 1.3.12 (canary) — both missing the method.
Suggested fix
Use the synchronous dns module for this call instead of dns.promises:
import dns from 'node:dns'
// ...
if (dns.getDefaultResultOrder() === 'verbatim') {
Or import both:
import { promises as dnsPromises } from 'node:dns'
import dns from 'node:dns'
getDefaultResultOrder is a synchronous function by nature, so using dns.promises for it is unnecessary.
Environment
- Vite: 8.0.6 (broken), 8.0.5 (works)
- Runtime: Bun 1.3.10 / 1.3.11 / 1.3.12-canary
- OS: Linux (Docker
oven/bun:1.3)
Description
Since Vite 8.0.6, running
vite buildunder the Bun runtime fails with:This works fine with Vite 8.0.5 and earlier.
Root cause
Introduced by commit 56ec256 (PR #22151): "perf: early return in
getLocalhostAddressIfDiffersFromDNSwhen DNS order is verbatim".packages/vite/src/node/utils.tsimports:The new early-return guard added by that PR calls:
Because
dnsis aliased fromdns.promises, this resolves at runtime todns.promises.getDefaultResultOrder().Bun implements
dns.getDefaultResultOrder(sync) but notdns.promises.getDefaultResultOrder. Tested on Bun 1.3.11 (latest stable) and 1.3.12 (canary) — both missing the method.Suggested fix
Use the synchronous
dnsmodule for this call instead ofdns.promises:Or import both:
getDefaultResultOrderis a synchronous function by nature, so usingdns.promisesfor it is unnecessary.Environment
oven/bun:1.3)