Skip to content

Commit 15f1c15

Browse files
authored
fix: avoid dns.getDefaultResultOrder temporary (#22202)
1 parent 6baf587 commit 15f1c15

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/vite/src/node/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import crypto from 'node:crypto'
77
import { fileURLToPath } from 'node:url'
88
import type { ServerOptions as HttpsServerOptions } from 'node:https'
99
import { builtinModules } from 'node:module'
10-
import { promises as dns, getDefaultResultOrder } from 'node:dns'
10+
import { promises as dns } from 'node:dns'
1111
import { performance } from 'node:perf_hooks'
1212
import type { AddressInfo, Server } from 'node:net'
1313
import fsp from 'node:fs/promises'
@@ -925,7 +925,10 @@ export function unique<T>(arr: T[]): T[] {
925925
export function getLocalhostAddressIfDiffersFromDNS():
926926
| Promise<string | undefined>
927927
| undefined {
928-
if (getDefaultResultOrder() === 'verbatim') {
928+
// dns.getDefaultResultOrder is not available in bun 1.3.11 and deno 2.7.11
929+
// while this is a bug in bun and deno, since this function is commonly called,
930+
// we give a workaround specially until the API is supported in a few versions
931+
if (dns.getDefaultResultOrder && dns.getDefaultResultOrder() === 'verbatim') {
929932
return undefined
930933
}
931934
return Promise.all([

0 commit comments

Comments
 (0)