Skip to content

Commit fd12582

Browse files
committed
feat(cli): support network family autoselection timeout
1 parent 6a363a3 commit fd12582

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/cli.zig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const DotEnv = @import("./env_loader.zig");
3636
const RunCommand_ = @import("./cli/run_command.zig").RunCommand;
3737
const CreateCommand_ = @import("./cli/create_command.zig").CreateCommand;
3838
const FilterRun = @import("./cli/filter_run.zig");
39+
const NodeNetBinding = @import("./bun.js/node/node_net_binding.zig");
3940

4041
const fs = @import("fs.zig");
4142
const Router = @import("./router.zig");
@@ -240,6 +241,7 @@ pub const Arguments = struct {
240241
clap.parseParam("--fetch-preconnect <STR>... Preconnect to a URL while code is loading") catch unreachable,
241242
clap.parseParam("--max-http-header-size <INT> Set the maximum size of HTTP headers in bytes. Default is 16KiB") catch unreachable,
242243
clap.parseParam("--dns-result-order <STR> Set the default order of DNS lookup results. Valid orders: verbatim (default), ipv4first, ipv6first") catch unreachable,
244+
clap.parseParam("--network-family-autoselection-attempt-timeout <INT> Set the default timeout in ms for network family autoselection") catch unreachable,
243245
clap.parseParam("--expose-gc Expose gc() on the global object. Has no effect on Bun.gc().") catch unreachable,
244246
clap.parseParam("--no-deprecation Suppress all reporting of the custom deprecation.") catch unreachable,
245247
clap.parseParam("--throw-deprecation Determine whether or not deprecation warnings result in errors.") catch unreachable,
@@ -812,6 +814,16 @@ pub const Arguments = struct {
812814
ctx.runtime_options.dns_result_order = order;
813815
}
814816

817+
if (args.option("--network-family-autoselection-attempt-timeout")) |timeout_str| {
818+
var timeout = std.fmt.parseInt(u32, timeout_str, 10) catch {
819+
Output.errGeneric("Invalid value for --network-family-autoselection-attempt-timeout: \"{s}\". Must be a positive integer\n", .{timeout_str});
820+
Global.exit(1);
821+
};
822+
if (timeout < 10)
823+
timeout = 10;
824+
NodeNetBinding.autoSelectFamilyAttemptTimeoutDefault = timeout;
825+
}
826+
815827
if (args.option("--inspect")) |inspect_flag| {
816828
ctx.runtime_options.debugger = if (inspect_flag.len == 0)
817829
Command.Debugger{ .enable = .{} }

0 commit comments

Comments
 (0)