mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
bug(cli): Prefer IPv4 dns resolution by default. (#5338)
This commit is contained in:
@@ -12,9 +12,11 @@ import { readStdin } from './utils/readStdin.js';
|
||||
import { basename } from 'node:path';
|
||||
import v8 from 'node:v8';
|
||||
import os from 'node:os';
|
||||
import dns from 'node:dns';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { start_sandbox } from './utils/sandbox.js';
|
||||
import {
|
||||
DnsResolutionOrder,
|
||||
LoadedSettings,
|
||||
loadSettings,
|
||||
SettingScope,
|
||||
@@ -44,6 +46,23 @@ import { checkForUpdates } from './ui/utils/updateCheck.js';
|
||||
import { handleAutoUpdate } from './utils/handleAutoUpdate.js';
|
||||
import { appEvents, AppEvent } from './utils/events.js';
|
||||
|
||||
export function validateDnsResolutionOrder(
|
||||
order: string | undefined,
|
||||
): DnsResolutionOrder {
|
||||
const defaultValue: DnsResolutionOrder = 'ipv4first';
|
||||
if (order === undefined) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (order === 'ipv4first' || order === 'verbatim') {
|
||||
return order;
|
||||
}
|
||||
// We don't want to throw here, just warn and use the default.
|
||||
console.warn(
|
||||
`Invalid value for dnsResolutionOrder in settings: "${order}". Using default "${defaultValue}".`,
|
||||
);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
function getNodeMemoryArgs(config: Config): string[] {
|
||||
const totalMemoryMB = os.totalmem() / (1024 * 1024);
|
||||
const heapStats = v8.getHeapStatistics();
|
||||
@@ -138,6 +157,10 @@ export async function main() {
|
||||
argv,
|
||||
);
|
||||
|
||||
dns.setDefaultResultOrder(
|
||||
validateDnsResolutionOrder(settings.merged.dnsResolutionOrder),
|
||||
);
|
||||
|
||||
if (argv.promptInteractive && !process.stdin.isTTY) {
|
||||
console.error(
|
||||
'Error: The --prompt-interactive flag is not supported when piping input from stdin.',
|
||||
|
||||
Reference in New Issue
Block a user