Skip to content

Commit

Permalink
fix(http) timeout (#12728)
Browse files Browse the repository at this point in the history
Co-authored-by: cirospaciari <[email protected]>
Co-authored-by: Jarred Sumner <[email protected]>
  • Loading branch information
3 people authored Jul 23, 2024
1 parent 4e5d759 commit 5a5f3d6
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 111 deletions.
1 change: 0 additions & 1 deletion misctools/fetch.zig
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ pub fn main() anyerror!void {
args.headers_buf,
response_body_string,
args.body,
0,
HTTP.FetchRedirect.follow,
),
};
Expand Down
7 changes: 0 additions & 7 deletions misctools/http_bench.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const params = [_]clap.Param(clap.Help){
clap.parseParam("-b, --body <STR> HTTP request body as a string") catch unreachable,
clap.parseParam("-f, --file <STR> File path to load as body") catch unreachable,
clap.parseParam("-n, --count <INT> How many runs? Default 10") catch unreachable,
clap.parseParam("-t, --timeout <INT> Max duration per request") catch unreachable,
clap.parseParam("-r, --retry <INT> Max retry count") catch unreachable,
clap.parseParam("--no-gzip Disable gzip") catch unreachable,
clap.parseParam("--no-deflate Disable deflate") catch unreachable,
Expand Down Expand Up @@ -75,7 +74,6 @@ pub const Arguments = struct {
body: string = "",
turbo: bool = false,
count: usize = 10,
timeout: usize = 0,
repeat: usize = 0,
concurrency: u16 = 32,

Expand Down Expand Up @@ -165,10 +163,6 @@ pub const Arguments = struct {
// .keep_alive = !args.flag("--no-keep-alive"),
.concurrency = std.fmt.parseInt(u16, args.option("--max-concurrency") orelse "32", 10) catch 32,
.turbo = args.flag("--turbo"),
.timeout = std.fmt.parseInt(usize, args.option("--timeout") orelse "0", 10) catch |err| {
Output.prettyErrorln("<r><red>{s}<r> parsing timeout", .{@errorName(err)});
Global.exit(1);
},
.count = std.fmt.parseInt(usize, args.option("--count") orelse "10", 10) catch |err| {
Output.prettyErrorln("<r><red>{s}<r> parsing count", .{@errorName(err)});
Global.exit(1);
Expand Down Expand Up @@ -225,7 +219,6 @@ pub fn main() anyerror!void {
args.headers_buf,
response_body,
"",
args.timeout,
),
};
ctx.http.client.verbose = args.verbose;
Expand Down
3 changes: 0 additions & 3 deletions src/bun.js/webcore/response.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,6 @@ pub const Fetch = struct {
fetch_options.headers.buf.items,
&fetch_tasklet.response_buffer,
fetch_tasklet.request_body.slice(),
fetch_options.timeout,
http.HTTPClientResult.Callback.New(
*FetchTasklet,
FetchTasklet.callback,
Expand Down Expand Up @@ -1681,7 +1680,6 @@ pub const Fetch = struct {
method: Method,
headers: Headers,
body: HTTPRequestBody,
timeout: usize,
disable_timeout: bool,
disable_keepalive: bool,
disable_decompression: bool,
Expand Down Expand Up @@ -2799,7 +2797,6 @@ pub const Fetch = struct {
.allocator = allocator,
},
.body = http_body,
.timeout = std.time.ns_per_hour,
.disable_keepalive = disable_keepalive,
.disable_timeout = disable_timeout,
.disable_decompression = disable_decompression,
Expand Down
5 changes: 0 additions & 5 deletions src/cli/create_command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,6 @@ pub const Example = struct {

const examples_url: string = "https://registry.npmjs.org/bun-examples-all/latest";
var url: URL = undefined;
pub const timeout: u32 = 6000;

var app_name_buf: [512]u8 = undefined;
pub fn print(examples: []const Example, default_app_name: ?string) void {
Expand Down Expand Up @@ -1977,7 +1976,6 @@ pub const Example = struct {
headers_buf,
mutable,
"",
60 * std.time.ns_per_min,
http_proxy,
null,
HTTP.FetchRedirect.follow,
Expand Down Expand Up @@ -2055,7 +2053,6 @@ pub const Example = struct {
"",
mutable,
"",
60 * std.time.ns_per_min,
http_proxy,
null,
HTTP.FetchRedirect.follow,
Expand Down Expand Up @@ -2145,7 +2142,6 @@ pub const Example = struct {
"",
mutable,
"",
60 * std.time.ns_per_min,
http_proxy,
null,
HTTP.FetchRedirect.follow,
Expand Down Expand Up @@ -2188,7 +2184,6 @@ pub const Example = struct {
"",
mutable,
"",
60 * std.time.ns_per_min,
http_proxy,
null,
HTTP.FetchRedirect.follow,
Expand Down
4 changes: 0 additions & 4 deletions src/cli/upgrade_command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ pub const UpgradeCheckerThread = struct {
};

pub const UpgradeCommand = struct {
pub const timeout: u32 = 30000;
const default_github_headers: string = "Acceptapplication/vnd.github.v3+json";
var github_repository_url_buf: bun.PathBuffer = undefined;
var current_executable_buf: bun.PathBuffer = undefined;
Expand Down Expand Up @@ -245,7 +244,6 @@ pub const UpgradeCommand = struct {
headers_buf,
&metadata_body,
"",
60 * std.time.ns_per_min,
http_proxy,
null,
HTTP.FetchRedirect.follow,
Expand Down Expand Up @@ -528,12 +526,10 @@ pub const UpgradeCommand = struct {
"",
zip_file_buffer,
"",
timeout,
http_proxy,
null,
HTTP.FetchRedirect.follow,
);
async_http.client.timeout = timeout;
async_http.client.progress_node = progress;
async_http.client.reject_unauthorized = env_loader.getTLSRejectUnauthorized();

Expand Down
3 changes: 0 additions & 3 deletions src/compile_target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ pub fn downloadToPath(this: *const CompileTarget, env: *bun.DotEnv.Loader, alloc
{
var progress = refresher.start("Downloading", 0);
defer progress.end();
const timeout = 30000;
const http_proxy: ?bun.URL = env.getHttpProxy(url);

async_http.* = HTTP.AsyncHTTP.initSync(
Expand All @@ -164,12 +163,10 @@ pub fn downloadToPath(this: *const CompileTarget, env: *bun.DotEnv.Loader, alloc
"",
compressed_archive_bytes,
"",
timeout,
http_proxy,
null,
HTTP.FetchRedirect.follow,
);
async_http.client.timeout = timeout;
async_http.client.progress_node = progress;
async_http.client.reject_unauthorized = env.getTLSRejectUnauthorized();

Expand Down
Loading

0 comments on commit 5a5f3d6

Please sign in to comment.