Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,17 +922,21 @@ export function unique<T>(arr: T[]): T[] {
* Even if defaultResultOrder is `ipv4first`, `dns.lookup` result maybe same.
* For example, when IPv6 is not supported on that machine/network.
*/
export async function getLocalhostAddressIfDiffersFromDNS(): Promise<
string | undefined
> {
const [nodeResult, dnsResult] = await Promise.all([
export function getLocalhostAddressIfDiffersFromDNS():
| Promise<string | undefined>
| undefined {
if (dns.getDefaultResultOrder() === 'verbatim') {
return undefined
}
return Promise.all([
dns.lookup('localhost'),
dns.lookup('localhost', { verbatim: true }),
])
const isSame =
nodeResult.family === dnsResult.family &&
nodeResult.address === dnsResult.address
return isSame ? undefined : nodeResult.address
]).then(([nodeResult, dnsResult]) => {
const isSame =
nodeResult.family === dnsResult.family &&
nodeResult.address === dnsResult.address
return isSame ? undefined : nodeResult.address
})
}

export function diffDnsOrderChange(
Expand Down
Loading