diff options
author | 2022-03-15 05:00:06 -0700 | |
---|---|---|
committer | 2022-03-15 05:00:06 -0700 | |
commit | 234dd04c86791ea0e608e0a352df61e7654bda0a (patch) | |
tree | f6b35d824613f5bb01a366fbf1b2b6f18b8c9997 /src/bun_js.zig | |
parent | 6f095a63946470721d1dde4e527b60cbc2a9f515 (diff) | |
download | bun-234dd04c86791ea0e608e0a352df61e7654bda0a.tar.gz bun-234dd04c86791ea0e608e0a352df61e7654bda0a.tar.zst bun-234dd04c86791ea0e608e0a352df61e7654bda0a.zip |
higher max http requests for bun.js
Diffstat (limited to '')
-rw-r--r-- | src/bun_js.zig | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/bun_js.zig b/src/bun_js.zig index ea1fe4ba1..716b1dfa7 100644 --- a/src/bun_js.zig +++ b/src/bun_js.zig @@ -30,6 +30,7 @@ const DotEnv = @import("env_loader.zig"); const which = @import("which.zig").which; const VirtualMachine = @import("javascript_core").VirtualMachine; const JSC = @import("javascript_core"); +const AsyncHTTP = @import("http").AsyncHTTP; const OpaqueWrap = JSC.OpaqueWrap; @@ -80,6 +81,34 @@ pub const Run = struct { Global.exit(1); }; + AsyncHTTP.max_simultaneous_requests = 255; + + if (run.vm.bundler.env.map.get("BUN_CONFIG_MAX_HTTP_REQUESTS")) |max_http_requests| { + load: { + AsyncHTTP.max_simultaneous_requests = std.fmt.parseInt(u16, max_http_requests, 10) catch { + run.vm.log.addErrorFmt( + null, + logger.Loc.Empty, + run.vm.allocator, + "BUN_CONFIG_MAX_HTTP_REQUESTS value \"{s}\" is not a valid integer between 1 and 65535", + .{max_http_requests}, + ) catch unreachable; + break :load; + }; + + if (AsyncHTTP.max_simultaneous_requests == 0) { + run.vm.log.addWarningFmt( + null, + logger.Loc.Empty, + run.vm.allocator, + "BUN_CONFIG_MAX_HTTP_REQUESTS value must be a number between 1 and 65535", + .{}, + ) catch unreachable; + AsyncHTTP.max_simultaneous_requests = 255; + } + } + } + var callback = OpaqueWrap(Run, Run.start); run.vm.global.vm().holdAPILock(&run, callback); } |