()
| 922 | * For example, when IPv6 is not supported on that machine/network. |
| 923 | */ |
| 924 | export function getLocalhostAddressIfDiffersFromDNS(): |
| 925 | | Promise<string | undefined> |
| 926 | | undefined { |
| 927 | // dns.getDefaultResultOrder is not available in bun 1.3.11 and deno 2.7.11 |
| 928 | // while this is a bug in bun and deno, since this function is commonly called, |
| 929 | // we give a workaround specially until the API is supported in a few versions |
| 930 | if (dns.getDefaultResultOrder && dns.getDefaultResultOrder() === 'verbatim') { |
| 931 | return undefined |
| 932 | } |
| 933 | return Promise.all([ |
| 934 | dns.lookup('localhost'), |
| 935 | dns.lookup('localhost', { verbatim: true }), |
| 936 | ]).then(([nodeResult, dnsResult]) => { |
| 937 | const isSame = |
| 938 | nodeResult.family === dnsResult.family && |
| 939 | nodeResult.address === dnsResult.address |
| 940 | return isSame ? undefined : nodeResult.address |
| 941 | }) |
| 942 | } |
| 943 | |
| 944 | export function diffDnsOrderChange( |
| 945 | oldUrls: ViteDevServer['resolvedUrls'], |
no outgoing calls
no test coverage detected