aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-10-28 16:39:26 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-10-28 16:39:26 -0700
commitfb10e0c4cb35b78630994c7a7ade5be123011b1b (patch)
tree3d26edb35b6adbb4aa6e88ee2655db571cfb4303
parenta44cb9708f8a1460a2851bc3357d2cec655f7ee2 (diff)
downloadbun-fb10e0c4cb35b78630994c7a7ade5be123011b1b.tar.gz
bun-fb10e0c4cb35b78630994c7a7ade5be123011b1b.tar.zst
bun-fb10e0c4cb35b78630994c7a7ade5be123011b1b.zip
Upgrade checker + polish for `bun upgrade`
-rw-r--r--.vscode/launch.json96
-rw-r--r--src/cli/run_command.zig56
-rw-r--r--src/cli/upgrade_command.zig78
-rw-r--r--src/http.zig4
-rw-r--r--src/http_client.zig2
-rw-r--r--src/s2n.zig2
6 files changed, 150 insertions, 88 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 12b0881ea..a9cf56a9f 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -4,15 +4,6 @@
{
"type": "lldb",
"request": "launch",
- "name": "tgz debug",
- "program": "${workspaceFolder}/tgz",
- "args": ["./bun-examples-all-0.0.1634264480817.tgz"],
- "cwd": "${workspaceFolder}",
- "console": "internalConsole"
- },
- {
- "type": "lldb",
- "request": "launch",
"name": "fetch debug",
"program": "${workspaceFolder}/misctools/fetch",
"args": ["https://api.github.com/repos/hanford/trends/tarball"],
@@ -23,7 +14,7 @@
"type": "lldb",
"request": "launch",
"name": "bun create debug",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["create", "hanford/trends", "foo"],
"cwd": "/tmp/",
"console": "internalConsole"
@@ -31,8 +22,17 @@
{
"type": "lldb",
"request": "launch",
+ "name": "bun run debug",
+ "program": "bun-debug",
+ "args": ["paoskdpoasdk"],
+ "cwd": "/tmp/",
+ "console": "internalConsole"
+ },
+ {
+ "type": "lldb",
+ "request": "launch",
"name": "bun a debug",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["create", "https://github.com/ahfarmer/calculator", "--force"],
"cwd": "/tmp/",
"console": "internalConsole"
@@ -41,7 +41,7 @@
"type": "lldb",
"request": "launch",
"name": "bun routes",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [],
"cwd": "${workspaceFolder}/integration/apps/routing",
"console": "internalConsole"
@@ -64,7 +64,7 @@
"type": "lldb",
"request": "launch",
"name": ".bun",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [
"./examples/hello-next/node_modules.server.bun"
// "--origin=https://localhost:9000/"
@@ -76,7 +76,7 @@
"type": "lldb",
"request": "launch",
"name": "Discord",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [
"discord"
// "--origin=https://localhost:9000/"
@@ -101,7 +101,7 @@
"type": "lldb",
"request": "launch",
"name": "Dev Launch",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [
"./simple.css",
"--resolve=dev",
@@ -135,7 +135,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Serve",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
// "args": ["--serve", "--origin=http://localhost:3000"],
"args": ["dev", "--origin=http://localhost:3000"],
"cwd": "${workspaceFolder}/examples/hello-next",
@@ -155,7 +155,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Lazy Build",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [
"./src/index.tsx",
"--resolve=lazy",
@@ -169,7 +169,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Build",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [
"./src/index.tsx",
"--resolve=dev",
@@ -184,7 +184,7 @@
"type": "lldb",
"request": "launch",
"name": "Dazzle serve",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["--origin=http://localhost:5000", "--disable-hmr"],
"cwd": "/Users/jarred/Build/lattice/apps/dazzle",
"console": "internalConsole"
@@ -193,7 +193,7 @@
"type": "lldb",
"request": "launch",
"name": "Bun",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["bun", "--use=next"],
"cwd": "/Users/jarred/Build/lattice/apps/dazzle",
"console": "internalConsole"
@@ -203,7 +203,7 @@
"request": "launch",
"name": "unicode check",
"args": ["--disable-hmr"],
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"cwd": "/Users/jarred/Build/app994",
"console": "internalConsole"
},
@@ -212,7 +212,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo .bun",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["bun", "--use=bun-framework-next"],
"cwd": "${workspaceFolder}/examples/hello-next",
"console": "internalConsole"
@@ -221,7 +221,7 @@
"type": "lldb",
"request": "launch",
"name": "PNPM .bun",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["bun", "./pages/index.js"],
"cwd": "/Users/jarred/Build/pnpm-bun/packages/app",
"console": "internalConsole"
@@ -231,7 +231,7 @@
"type": "lldb",
"request": "launch",
"name": "PNPM serve",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [],
"cwd": "/Users/jarred/Build/pnpm-bun/packages/app",
"console": "internalConsole"
@@ -240,7 +240,7 @@
"type": "lldb",
"request": "launch",
"name": "Mixed case resolve",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [
"build",
"./index.js",
@@ -255,7 +255,7 @@
"type": "lldb",
"request": "launch",
"name": "Build .bun lotta-modules",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["bun", "./index.js", "--platform=browser"],
"cwd": "${workspaceFolder}/examples/lotta-modules/",
"console": "internalConsole"
@@ -264,7 +264,7 @@
"type": "lldb",
"request": "launch",
"name": "Dev CRA",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["dev", "--platform=browser"],
"cwd": "${workspaceFolder}/examples/hello-create-react-app/",
"console": "internalConsole"
@@ -273,7 +273,7 @@
"type": "lldb",
"request": "launch",
"name": "Fragment",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [],
"cwd": "${workspaceFolder}/src/test/fixtures",
"console": "internalConsole"
@@ -282,7 +282,7 @@
"type": "lldb",
"request": "launch",
"name": "Context Bun Bug",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["bun", "./code.js"],
"cwd": "/Users/jarred/Build/context/www",
"console": "internalConsole"
@@ -291,7 +291,7 @@
"type": "lldb",
"request": "launch",
"name": "Context Bun",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["bun", "--use=next"],
"cwd": "/Users/jarred/Build/context/www",
"console": "internalConsole"
@@ -300,7 +300,7 @@
"type": "lldb",
"request": "launch",
"name": "Bun-hello",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [],
"cwd": "${workspaceFolder}/packages/bun-hello",
"console": "internalConsole"
@@ -309,7 +309,7 @@
"type": "lldb",
"request": "launch",
"name": "Integration Test Dev",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [],
"cwd": "${workspaceFolder}/integration/snippets",
"console": "internalConsole"
@@ -318,7 +318,7 @@
"type": "lldb",
"request": "launch",
"name": "Integration Test Dev (no hmr)",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["--disable-hmr"],
"cwd": "${workspaceFolder}/integration/snippets",
"console": "internalConsole"
@@ -346,7 +346,7 @@
"request": "launch",
"name": "Context Dev",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [],
"cwd": "/Users/jarred/Build/context/www",
"console": "internalConsole"
@@ -365,7 +365,7 @@
"type": "lldb",
"request": "launch",
"name": "Debug Dev",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["dev"],
"cwd": "${workspaceFolder}/examples/hello-next",
"console": "internalConsole"
@@ -374,7 +374,7 @@
"type": "lldb",
"request": "launch",
"name": "Type-only import",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [
"bun",
"./src/test/fixtures/type-only-import.ts",
@@ -387,7 +387,7 @@
"type": "lldb",
"request": "launch",
"name": "Dev lotta-modules",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["dev", "./index.js", "--platform=browser"],
"cwd": "${workspaceFolder}/examples/lotta-modules/",
"console": "internalConsole"
@@ -396,7 +396,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Build .bun",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": [
"bun",
// "./index.js",
@@ -411,7 +411,7 @@
"type": "lldb",
"request": "launch",
"name": "PNPM Resolve symlink",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["--resolve=dev", "test-pnpm.js", "--platform=browser"],
"cwd": "${workspaceFolder}/examples/css-stress-test",
"console": "internalConsole"
@@ -420,7 +420,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Print .bun",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ "program": "bun-debug",
"args": ["./node_modules.bun"],
"cwd": "${workspaceFolder}/examples/simple-react",
"console": "internalConsole"
@@ -449,7 +449,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch (other)",
- // "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ // "program": "bun-debug",
// "args": ["./simple.jsx", "--resolve=disable"],
// "cwd": "${workspaceFolder}/src/test/fixtures",
// "console": "internalConsole"
@@ -458,7 +458,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
- // "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ // "program": "bun-debug",
// "preLaunchTask": "build",
// "args": [
// "--resolve=disable",
@@ -473,7 +473,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
- // "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ // "program": "bun-debug",
// "preLaunchTask": "build",
// "args": [
// "--resolve=dev",
@@ -490,7 +490,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
- // "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ // "program": "bun-debug",
// "preLaunchTask": "build",
// "args": [
// "--resolve=dev",
@@ -507,7 +507,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
- // "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ // "program": "bun-debug",
// // "preLaunchTask": "build",
// "args": [
// "--resolve=dev",
@@ -526,7 +526,7 @@
"type": "lldb",
"request": "launch",
"name": "Rome",
- // "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ // "program": "bun-debug",
"program": "${workspaceFolder}/build/macos-x86_64/bun",
// "preLaunchTask": "build",
"args": [
@@ -548,8 +548,8 @@
"type": "lldb",
"request": "launch",
"name": "Rome Dev",
- // "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
- "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
+ // "program": "bun-debug",
+ "program": "bun-debug",
// "preLaunchTask": "build",
"args": [
"--resolve=dev",
diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig
index b2dc426ef..bd0bb8322 100644
--- a/src/cli/run_command.zig
+++ b/src/cli/run_command.zig
@@ -555,33 +555,39 @@ pub const RunCommand = struct {
var path_for_which = PATH;
if (comptime bin_dirs_only) {
- path_for_which = PATH[0 .. PATH.len - (ORIGINAL_PATH.len + 1)];
- }
+ path_for_which = "";
- if (which(&path_buf, path_for_which, this_bundler.fs.top_level_dir, script_name_to_search)) |destination| {
- var file = std.fs.openFileAbsoluteZ(destination, .{ .read = true }) catch |err| {
- if (!log_errors) return false;
+ if (ORIGINAL_PATH.len < PATH.len) {
+ path_for_which = PATH[0 .. PATH.len - (ORIGINAL_PATH.len + 1)];
+ }
+ }
- Output.prettyErrorln("<r>error: <red>{s}<r> opening file: \"{s}\"", .{ err, std.mem.span(destination) });
- Output.flush();
- return err;
- };
- var outbuf = std.os.getFdPath(file.handle, &path_buf2) catch |err| {
- if (!log_errors) return false;
- Output.prettyErrorln("<r>error: <red>{s}<r> resolving file: \"{s}\"", .{ err, std.mem.span(destination) });
- Output.flush();
- return err;
- };
-
- file.close();
-
- return try runBinary(
- ctx,
- try this_bundler.fs.dirname_store.append([]u8, outbuf),
- this_bundler.fs.top_level_dir,
- this_bundler.env,
- passthrough,
- );
+ if (path_for_which.len > 0) {
+ if (which(&path_buf, path_for_which, this_bundler.fs.top_level_dir, script_name_to_search)) |destination| {
+ var file = std.fs.openFileAbsoluteZ(destination, .{ .read = true }) catch |err| {
+ if (!log_errors) return false;
+
+ Output.prettyErrorln("<r>error: <red>{s}<r> opening file: \"{s}\"", .{ err, std.mem.span(destination) });
+ Output.flush();
+ return err;
+ };
+ var outbuf = std.os.getFdPath(file.handle, &path_buf2) catch |err| {
+ if (!log_errors) return false;
+ Output.prettyErrorln("<r>error: <red>{s}<r> resolving file: \"{s}\"", .{ err, std.mem.span(destination) });
+ Output.flush();
+ return err;
+ };
+
+ file.close();
+
+ return try runBinary(
+ ctx,
+ try this_bundler.fs.dirname_store.append([]u8, outbuf),
+ this_bundler.fs.top_level_dir,
+ this_bundler.env,
+ passthrough,
+ );
+ }
}
if (comptime log_errors) {
diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig
index 8dc83a037..441369a93 100644
--- a/src/cli/upgrade_command.zig
+++ b/src/cli/upgrade_command.zig
@@ -69,13 +69,46 @@ pub const Version = struct {
}
};
+pub const UpgradeCheckerThread = struct {
+ pub fn spawn(env_loader: *DotEnv.Loader) void {
+ if (env_loader.map.get("BUN_DISABLE_UPGRADE_CHECK") != null or env_loader.map.get("CI") != null) return;
+ var thread = std.Thread.spawn(.{}, run, .{env_loader}) catch return;
+ thread.setName("Update Checker") catch {};
+ thread.detach();
+ }
+
+ fn _run(env_loader: *DotEnv.Loader) anyerror!void {
+ var rand = std.rand.DefaultPrng.init(@intCast(u64, @maximum(std.time.milliTimestamp(), 0)));
+ const delay = rand.random.intRangeAtMost(u64, 100, 10000);
+ std.time.sleep(std.time.ns_per_ms * delay);
+
+ const version = (try UpgradeCommand.getLatestVersion(default_allocator, env_loader, undefined, undefined, true)) orelse return;
+
+ if (!version.isCurrent()) {
+ if (version.name()) |name| {
+ Output.Source.configureThread();
+ Output.prettyErrorln("\n<r><d>Bun v{s} is out. Run <b><cyan>bun upgrade<r> to upgrade.\n", .{name});
+ Output.flush();
+ }
+ }
+ }
+
+ fn run(env_loader: *DotEnv.Loader) void {
+ _run(env_loader) catch |err| {
+ if (Environment.isDebug) {
+ std.debug.print("\n[UpgradeChecker] ERROR: {s}\n", .{@errorName(err)});
+ }
+ };
+ }
+};
+
pub const UpgradeCommand = struct {
pub const timeout: u32 = 30000;
const default_github_headers = "Acceptapplication/vnd.github.v3+json";
var github_repository_url_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
-
var current_executable_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
var unzip_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ var tmpdir_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
pub fn getLatestVersion(
allocator: *std.mem.Allocator,
@@ -271,7 +304,7 @@ pub const UpgradeCommand = struct {
return null;
}
- const exe_subpath = Version.folder_name;
+ const exe_subpath = Version.folder_name ++ std.fs.path.sep_str ++ "bun";
pub fn exec(ctx: Command.Context) !void {
var filesystem = try fs.FileSystem.init1(ctx.allocator, null);
@@ -338,9 +371,6 @@ pub const UpgradeCommand = struct {
&zip_file_buffer,
);
- progress.end();
- refresher.refresh();
-
switch (response.status_code) {
404 => return error.HTTP404,
403 => return error.HTTPForbidden,
@@ -351,6 +381,10 @@ pub const UpgradeCommand = struct {
}
var bytes = zip_file_buffer.toOwnedSliceLeaky();
+
+ progress.end();
+ refresher.refresh();
+
if (bytes.len == 0) {
Output.prettyErrorln("<r><red>error:<r> Failed to download the latest version of Bun. Received empty content", .{});
Output.flush();
@@ -365,6 +399,15 @@ pub const UpgradeCommand = struct {
Output.flush();
std.os.exit(1);
};
+ var tmpdir_path = std.os.getFdPath(save_dir.fd, &tmpdir_path_buf) catch |err| {
+ Output.prettyErrorln("<r><red>error:<r> Failed to read temporary directory", .{});
+ Output.flush();
+ std.os.exit(1);
+ };
+
+ tmpdir_path_buf[tmpdir_path.len] = 0;
+ var tmpdir_z = tmpdir_path_buf[0..tmpdir_path.len :0];
+ std.os.chdirZ(tmpdir_z) catch {};
const tmpname = "bun.zip";
@@ -395,17 +438,21 @@ pub const UpgradeCommand = struct {
Output.flush();
std.os.exit(1);
};
- Output.prettyErrorln("<r><b>Unzipping...<r>", .{});
- Output.flush();
+ // We could just embed libz2
+ // however, we want to be sure that xattrs are preserved
+ // xattrs are used for codesigning
+ // it'd be easy to mess that up
var unzip_argv = [_]string{
std.mem.span(unzip_exe),
+ "-q",
+ "-o",
std.mem.span(tmpname),
};
var unzip_process = try std.ChildProcess.init(&unzip_argv, ctx.allocator);
defer unzip_process.deinit();
- unzip_process.cwd_dir = save_dir;
+ unzip_process.cwd = tmpdir_path;
unzip_process.stdin_behavior = .Inherit;
unzip_process.stdout_behavior = .Inherit;
unzip_process.stderr_behavior = .Inherit;
@@ -434,7 +481,7 @@ pub const UpgradeCommand = struct {
const result = std.ChildProcess.exec(.{
.allocator = ctx.allocator,
.argv = &verify_argv,
- .cwd_dir = save_dir,
+ .cwd = tmpdir_path,
.max_output_bytes = 128,
}) catch |err| {
save_dir_.deleteTree(version_name) catch {};
@@ -444,12 +491,15 @@ pub const UpgradeCommand = struct {
};
if (result.term.Exited != 0) {
+ save_dir_.deleteTree(version_name) catch {};
Output.prettyErrorln("<r><red>error<r> failed to verify Bun<r> (exit code: {d})", .{result.term.Exited});
Output.flush();
std.os.exit(1);
}
if (!strings.eql(std.mem.trim(u8, result.stdout, " \n\r\t"), version_name)) {
+ save_dir_.deleteTree(version_name) catch {};
+
Output.prettyErrorln(
"<r><red>error<r>: The downloaded version of Bun (<red>{s}<r>) doesn't match the expected version (<b>{s}<r>)<r>. Cancelled upgrade",
.{
@@ -472,6 +522,7 @@ pub const UpgradeCommand = struct {
current_executable_buf[target_dir_.len] = 0;
var target_dirname = current_executable_buf[0..target_dir_.len :0];
var target_dir = std.fs.openDirAbsoluteZ(target_dirname, .{ .iterate = true }) catch |err| {
+ save_dir_.deleteTree(version_name) catch {};
Output.prettyErrorln("<r><red>error:<r> Failed to open Bun's install directory {s}", .{@errorName(err)});
Output.flush();
std.os.exit(1);
@@ -479,15 +530,16 @@ pub const UpgradeCommand = struct {
if (env_loader.map.get("BUN_DRY_RUN") == null) {
C.moveFileZ(save_dir.fd, exe_subpath, target_dir.fd, target_filename) catch |err| {
- Output.prettyErrorln("<r><red>error:<r> Failed to move new version of Bun due to {s}. You could try the install script instead:\n curl https://bun.sh/install | bash", .{@errorName(err)});
+ save_dir_.deleteTree(version_name) catch {};
+ Output.prettyErrorln("<r><red>error:<r> Failed to move new version of Bun due to {s}. You could try the install script instead:\n curl -L https://bun.sh/install | bash", .{@errorName(err)});
Output.flush();
std.os.exit(1);
};
}
- Output.prettyErrorln("\n", .{});
- Output.flush();
- Output.prettyln("<r><b><green>Upgraded successfully<r>. Welcome to Bun v{s}!\nFind out what's new: https://github.com/Jarred-Sumner/bun/releases<r>", .{version_name});
+ Output.printStartEnd(ctx.start_time, std.time.nanoTimestamp());
+
+ Output.prettyErrorln("<r> Upgraded.\n\n<b><green>Welcome to Bun v{s}!<r>\n\n Report any bugs:\n https://github.com/Jarred-Sumner/bun/issues\n\n What's new:\n https://github.com/Jarred-Sumner/bun/releases/tag/{s}<r>", .{ version_name, version.tag });
Output.flush();
return;
}
diff --git a/src/http.zig b/src/http.zig
index 896c54812..2ea79f953 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -2634,6 +2634,10 @@ pub const Server = struct {
Analytics.Features.filesystem_router = server.bundler.router != null;
Analytics.Features.bunjs = server.transform_options.node_modules_bundle_path_server != null;
+ const UpgradeCheckerThread = @import("./cli/upgrade_command.zig").UpgradeCheckerThread;
+
+ UpgradeCheckerThread.spawn(server.bundler.env);
+
var did_init = false;
while (!did_init) {
defer Output.flush();
diff --git a/src/http_client.zig b/src/http_client.zig
index 834bc9215..560bd0797 100644
--- a/src/http_client.zig
+++ b/src/http_client.zig
@@ -44,7 +44,7 @@ body_size: u32 = 0,
read_count: u32 = 0,
remaining_redirect_count: i8 = 127,
redirect_buf: [2048]u8 = undefined,
-disable_shutdown: bool = false,
+disable_shutdown: bool = true,
timeout: u32 = 0,
progress_node: ?*std.Progress.Node = null,
diff --git a/src/s2n.zig b/src/s2n.zig
index b99217b4c..6f7be069d 100644
--- a/src/s2n.zig
+++ b/src/s2n.zig
@@ -659,9 +659,9 @@ pub const Connection = struct {
pub fn close(this: *Connection) !void {
if (!this.disable_shutdown) {
_ = s2n_shutdown(this.conn, &blocked_status);
- Pool.put(this.node);
}
std.os.closeSocket(this.fd);
+ Pool.put(this.node);
}
pub const Writer = std.io.Writer(*Connection, WriteError, write);