diff options
Diffstat (limited to 'src/report.zig')
-rw-r--r-- | src/report.zig | 304 |
1 files changed, 164 insertions, 140 deletions
diff --git a/src/report.zig b/src/report.zig index 827f8072d..5bdd5e221 100644 --- a/src/report.zig +++ b/src/report.zig @@ -340,59 +340,67 @@ pub noinline fn globalError(err: anyerror, trace_: @TypeOf(@errorReturnTrace())) Global.exit(1); }, error.SystemFdQuotaExceeded => { - const limit = std.os.getrlimit(.NOFILE) catch std.mem.zeroes(std.os.rlimit); - if (comptime Environment.isMac) { - Output.prettyError( - \\ - \\<r><red>error<r>: Your computer ran out of file descriptors <d>(<red>SystemFdQuotaExceeded<r><d>)<r> - \\ - \\<d>Current limit: {d}<r> - \\ - \\To fix this, try running: - \\ - \\ <cyan>sudo launchctl limit maxfiles 2147483646<r> - \\ <cyan>ulimit -n 2147483646<r> - \\ - \\That will only work until you reboot. - \\ - , - .{ - limit.cur, - }, - ); + if (comptime Environment.isPosix) { + const limit = std.os.getrlimit(.NOFILE) catch std.mem.zeroes(std.os.rlimit); + if (comptime Environment.isMac) { + Output.prettyError( + \\ + \\<r><red>error<r>: Your computer ran out of file descriptors <d>(<red>SystemFdQuotaExceeded<r><d>)<r> + \\ + \\<d>Current limit: {d}<r> + \\ + \\To fix this, try running: + \\ + \\ <cyan>sudo launchctl limit maxfiles 2147483646<r> + \\ <cyan>ulimit -n 2147483646<r> + \\ + \\That will only work until you reboot. + \\ + , + .{ + limit.cur, + }, + ); + } else { + Output.prettyError( + \\ + \\<r><red>error<r>: Your computer ran out of file descriptors <d>(<red>SystemFdQuotaExceeded<r><d>)<r> + \\ + \\<d>Current limit: {d}<r> + \\ + \\To fix this, try running: + \\ + \\ <cyan>sudo echo -e "\nfs.file-max=2147483646\n" >> /etc/sysctl.conf<r> + \\ <cyan>sudo sysctl -p<r> + \\ <cyan>ulimit -n 2147483646<r> + \\ + , + .{ + limit.cur, + }, + ); + + if (bun.getenvZ("USER")) |user| { + if (user.len > 0) { + Output.prettyError( + \\ + \\If that still doesn't work, you may need to add these lines to /etc/security/limits.conf: + \\ + \\ <cyan>{s} soft nofile 2147483646<r> + \\ <cyan>{s} hard nofile 2147483646<r> + \\ + , + .{ user, user }, + ); + } + } + } } else { Output.prettyError( - \\ \\<r><red>error<r>: Your computer ran out of file descriptors <d>(<red>SystemFdQuotaExceeded<r><d>)<r> - \\ - \\<d>Current limit: {d}<r> - \\ - \\To fix this, try running: - \\ - \\ <cyan>sudo echo -e "\nfs.file-max=2147483646\n" >> /etc/sysctl.conf<r> - \\ <cyan>sudo sysctl -p<r> - \\ <cyan>ulimit -n 2147483646<r> - \\ , - .{ - limit.cur, - }, + .{}, ); - - if (bun.getenvZ("USER")) |user| { - if (user.len > 0) { - Output.prettyError( - \\ - \\If that still doesn't work, you may need to add these lines to /etc/security/limits.conf: - \\ - \\ <cyan>{s} soft nofile 2147483646<r> - \\ <cyan>{s} hard nofile 2147483646<r> - \\ - , - .{ user, user }, - ); - } - } } Global.exit(1); @@ -401,71 +409,77 @@ pub noinline fn globalError(err: anyerror, trace_: @TypeOf(@errorReturnTrace())) Global.exit(1); }, error.ProcessFdQuotaExceeded => { - const limit = std.os.getrlimit(.NOFILE) catch std.mem.zeroes(std.os.rlimit); - if (comptime Environment.isMac) { - Output.prettyError( - \\ - \\<r><red>error<r>: bun ran out of file descriptors <d>(<red>ProcessFdQuotaExceeded<r><d>)<r> - \\ - \\<d>Current limit: {d}<r> - \\ - \\To fix this, try running: - \\ - \\ <cyan>ulimit -n 2147483646<r> - \\ - \\You may also need to run: - \\ - \\ <cyan>sudo launchctl limit maxfiles 2147483646<r> - \\ - , - .{ - limit.cur, - }, - ); + if (comptime Environment.isPosix) { + const limit = std.os.getrlimit(.NOFILE) catch std.mem.zeroes(std.os.rlimit); + if (comptime Environment.isMac) { + Output.prettyError( + \\ + \\<r><red>error<r>: bun ran out of file descriptors <d>(<red>ProcessFdQuotaExceeded<r><d>)<r> + \\ + \\<d>Current limit: {d}<r> + \\ + \\To fix this, try running: + \\ + \\ <cyan>ulimit -n 2147483646<r> + \\ + \\You may also need to run: + \\ + \\ <cyan>sudo launchctl limit maxfiles 2147483646<r> + \\ + , + .{ + limit.cur, + }, + ); + } else { + Output.prettyError( + \\ + \\<r><red>error<r>: bun ran out of file descriptors <d>(<red>ProcessFdQuotaExceeded<r><d>)<r> + \\ + \\<d>Current limit: {d}<r> + \\ + \\To fix this, try running: + \\ + \\ <cyan>ulimit -n 2147483646<r> + \\ + \\That will only work for the current shell. To fix this for the entire system, run: + \\ + \\ <cyan>sudo echo -e "\nfs.file-max=2147483646\n" >> /etc/sysctl.conf<r> + \\ <cyan>sudo sysctl -p<r> + \\ + , + .{ + limit.cur, + }, + ); + + if (bun.getenvZ("USER")) |user| { + if (user.len > 0) { + Output.prettyError( + \\ + \\If that still doesn't work, you may need to add these lines to /etc/security/limits.conf: + \\ + \\ <cyan>{s} soft nofile 2147483646<r> + \\ <cyan>{s} hard nofile 2147483646<r> + \\ + , + .{ user, user }, + ); + } + } + } } else { - Output.prettyError( - \\ + Output.prettyErrorln( \\<r><red>error<r>: bun ran out of file descriptors <d>(<red>ProcessFdQuotaExceeded<r><d>)<r> - \\ - \\<d>Current limit: {d}<r> - \\ - \\To fix this, try running: - \\ - \\ <cyan>ulimit -n 2147483646<r> - \\ - \\That will only work for the current shell. To fix this for the entire system, run: - \\ - \\ <cyan>sudo echo -e "\nfs.file-max=2147483646\n" >> /etc/sysctl.conf<r> - \\ <cyan>sudo sysctl -p<r> - \\ , - .{ - limit.cur, - }, + .{}, ); - - if (bun.getenvZ("USER")) |user| { - if (user.len > 0) { - Output.prettyError( - \\ - \\If that still doesn't work, you may need to add these lines to /etc/security/limits.conf: - \\ - \\ <cyan>{s} soft nofile 2147483646<r> - \\ <cyan>{s} hard nofile 2147483646<r> - \\ - , - .{ user, user }, - ); - } - } } Global.exit(1); }, // The usage of `unreachable` in Zig's std.os may cause the file descriptor problem to show up as other errors error.NotOpenForReading, error.Unexpected => { - const limit = std.os.getrlimit(.NOFILE) catch std.mem.zeroes(std.os.rlimit); - if (trace_) |trace| { print_stacktrace: { var debug_info = std.debug.getSelfDebugInfo() catch break :print_stacktrace; @@ -474,48 +488,58 @@ pub noinline fn globalError(err: anyerror, trace_: @TypeOf(@errorReturnTrace())) } } - if (limit.cur > 0 and limit.cur < (8096 * 2)) { - Output.prettyError( - \\ - \\<r><red>error<r>: An unknown error ocurred, possibly due to low max file descriptors <d>(<red>Unexpected<r><d>)<r> - \\ - \\<d>Current limit: {d}<r> - \\ - \\To fix this, try running: - \\ - \\ <cyan>ulimit -n 2147483646<r> - \\ - , - .{ - limit.cur, - }, - ); + if (comptime Environment.isPosix) { + const limit = std.os.getrlimit(.NOFILE) catch std.mem.zeroes(std.os.rlimit); - if (Environment.isLinux) { - if (bun.getenvZ("USER")) |user| { - if (user.len > 0) { - Output.prettyError( - \\ - \\If that still doesn't work, you may need to add these lines to /etc/security/limits.conf: - \\ - \\ <cyan>{s} soft nofile 2147483646<r> - \\ <cyan>{s} hard nofile 2147483646<r> - \\ - , - .{ - user, - user, - }, - ); - } - } - } else if (Environment.isMac) { + if (limit.cur > 0 and limit.cur < (8096 * 2)) { Output.prettyError( \\ - \\If that still doesn't work, you may need to run: + \\<r><red>error<r>: An unknown error ocurred, possibly due to low max file descriptors <d>(<red>Unexpected<r><d>)<r> \\ - \\ <cyan>sudo launchctl limit maxfiles 2147483646<r> + \\<d>Current limit: {d}<r> + \\ + \\To fix this, try running: \\ + \\ <cyan>ulimit -n 2147483646<r> + \\ + , + .{ + limit.cur, + }, + ); + + if (Environment.isLinux) { + if (bun.getenvZ("USER")) |user| { + if (user.len > 0) { + Output.prettyError( + \\ + \\If that still doesn't work, you may need to add these lines to /etc/security/limits.conf: + \\ + \\ <cyan>{s} soft nofile 2147483646<r> + \\ <cyan>{s} hard nofile 2147483646<r> + \\ + , + .{ + user, + user, + }, + ); + } + } + } else if (Environment.isMac) { + Output.prettyError( + \\ + \\If that still doesn't work, you may need to run: + \\ + \\ <cyan>sudo launchctl limit maxfiles 2147483646<r> + \\ + , + .{}, + ); + } + } else { + Output.prettyError( + \\<r><red>error<r>: An unknown error ocurred <d>(<red>Unexpected<r><d>)<r> , .{}, ); |