diff options
-rw-r--r-- | build.zig | 2 | ||||
-rw-r--r-- | src/bundler.zig | 1 | ||||
-rw-r--r-- | src/cli.zig | 3 | ||||
-rw-r--r-- | src/cli/bun_command.zig | 6 | ||||
-rw-r--r-- | src/fs.zig | 18 | ||||
-rw-r--r-- | src/http.zig | 8 |
6 files changed, 37 insertions, 1 deletions
@@ -77,6 +77,8 @@ fn addInternalPackages(step: *std.build.LibExeObjStep, allocator: *std.mem.Alloc .path = pkgPath("src/http/network_thread.zig"), }; + thread_pool.dependencies = &.{ io, http }; + network_thread.dependencies = &.{ io, thread_pool, diff --git a/src/bundler.zig b/src/bundler.zig index a69100103..4c6c28043 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -430,6 +430,7 @@ pub const Bundler = struct { }, }; Output.flush(); + var writer = Output.writer(); std.json.stringify(bundler.env.map.*, opts, Output.writer()) catch unreachable; Output.flush(); } diff --git a/src/cli.zig b/src/cli.zig index 368ac4544..553bfbc49 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -161,6 +161,7 @@ pub const Arguments = struct { const debug_params = [_]ParamType{ clap.parseParam("--dump-environment-variables Dump environment variables from .env and process as JSON and quit. Useful for debugging") catch unreachable, + clap.parseParam("--dump-limits Dump system limits. Useful for debugging") catch unreachable, clap.parseParam("--disable-bun.js Disable Bun.js from loading in the dev server") catch unreachable, }; @@ -245,6 +246,7 @@ pub const Arguments = struct { ctx.debug.dump_environment_variables = args.flag("--dump-environment-variables"); ctx.debug.fallback_only = args.flag("--disable-bun.js"); + ctx.debug.dump_limits = args.flag("--dump-limits"); // var output_dir = args.option("--outdir"); var output_dir: ?string = null; @@ -565,6 +567,7 @@ pub const PrintBundleCommand = struct { pub const Command = struct { pub const DebugOptions = struct { dump_environment_variables: bool = false, + dump_limits: bool = false, fallback_only: bool = false, silent: bool = false, }; diff --git a/src/cli/bun_command.zig b/src/cli/bun_command.zig index a25b33c88..b8d7d3484 100644 --- a/src/cli/bun_command.zig +++ b/src/cli/bun_command.zig @@ -114,6 +114,12 @@ pub const BunCommand = struct { return; } + if (ctx.debug.dump_limits) { + fs.FileSystem.printLimits(); + std.os.exit(0); + return; + } + var generated_server = false; if (this_bundler.options.framework) |*framework| { if (framework.toAPI(allocator, this_bundler.fs.top_level_dir) catch null) |_server_conf| { diff --git a/src/fs.zig b/src/fs.zig index af32745cf..9e92eeaa4 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -480,6 +480,24 @@ pub const FileSystem = struct { return try allocator.dupe(u8, joined); } + pub fn printLimits() void { + const LIMITS = [_]std.os.rlimit_resource{ std.os.rlimit_resource.STACK, std.os.rlimit_resource.NOFILE }; + Output.print("{{\n", .{}); + + inline for (LIMITS) |limit_type, i| { + const limit = std.os.getrlimit(limit_type) catch return; + + if (i == 0) { + Output.print(" \"stack\": [{d}, {d}],\n", .{ limit.cur, limit.max }); + } else if (i == 1) { + Output.print(" \"files\": [{d}, {d}]\n", .{ limit.cur, limit.max }); + } + } + + Output.print("}}\n", .{}); + Output.flush(); + } + pub const RealFS = struct { entries_mutex: Mutex = Mutex.init(), entries: *EntriesOption.Map, diff --git a/src/http.zig b/src/http.zig index 11c3d4077..4f4bc131d 100644 --- a/src/http.zig +++ b/src/http.zig @@ -1159,7 +1159,7 @@ pub const RequestContext = struct { handler.handleJSError(.configure_defines, err) catch {}; return; }; - + var entry_point = boot; if (!std.fs.path.isAbsolute(entry_point)) { const resolved_entry_point = vm.bundler.resolver.resolve( @@ -3056,6 +3056,12 @@ pub const Server = struct { return; } + if (debug.dump_limits) { + Fs.FileSystem.printLimits(); + std.os.exit(0); + return; + } + if (debug.fallback_only or server.bundler.env.map.get("BUN_DISABLE_BUN_JS") != null) { RequestContext.fallback_only = true; RequestContext.JavaScriptHandler.javascript_disabled = true; |