Skip to content

build: dns.promises.getDefaultResultOrder is not implemented in Bun, breaking vite build since 8.0.6 #22184

Description

@valerii-kuzivanov

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions