aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-20 00:07:01 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-20 00:07:01 -0700
commit167948f5c3afc0a4dc482222e42bd255951084ff (patch)
tree2321040cd648947a9c89f62c4c645498da6edbb4
parent37d191bc02dd5255ce0d6675017d5c491327e768 (diff)
downloadbun-167948f5c3afc0a4dc482222e42bd255951084ff.tar.gz
bun-167948f5c3afc0a4dc482222e42bd255951084ff.tar.zst
bun-167948f5c3afc0a4dc482222e42bd255951084ff.zip
Fix incorrect `hostname` logic
Fixes https://github.com/oven-sh/bun/issues/1261
Diffstat (limited to '')
-rw-r--r--src/bun.js/api/server.zig26
-rw-r--r--src/bun.js/javascript.zig15
2 files changed, 28 insertions, 13 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index 10ef5e825..c3501019a 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -96,7 +96,7 @@ const linux = std.os.linux;
pub const ServerConfig = struct {
port: u16 = 0,
- hostname: [*:0]const u8 = "0.0.0.0",
+ hostname: [*:0]const u8 = "localhost",
// TODO: use webkit URL parser instead of bun's
base_url: URL = URL{},
@@ -2405,19 +2405,19 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
}
const hostname = bun.span(this.config.hostname);
+ // When "localhost" is specified, we omit the hostname entirely
+ // Otherwise, "curl http://localhost:3000" doesn't actually work due to IPV6 vs IPV4 issues
+ // This prints a spurious log si_destination_compare on macOS but only when debugger is connected
+ const host: [*:0]const u8 = if (hostname.len == 0 or (!ssl_enabled and strings.eqlComptime(hostname, "localhost")))
+ ""
+ else
+ this.config.hostname;
- if (!(hostname.len == 0 or strings.eqlComptime(hostname, "0.0.0.0"))) {
- this.app.listenWithConfig(*ThisServer, this, onListen, .{
- .port = this.config.port,
- .options = 0,
- });
- } else {
- this.app.listenWithConfig(*ThisServer, this, onListen, .{
- .port = this.config.port,
- .host = this.config.hostname,
- .options = 0,
- });
- }
+ this.app.listenWithConfig(*ThisServer, this, onListen, .{
+ .port = this.config.port,
+ .host = host,
+ .options = 0,
+ });
}
};
}
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig
index d52a864a9..eb3a5a455 100644
--- a/src/bun.js/javascript.zig
+++ b/src/bun.js/javascript.zig
@@ -350,7 +350,22 @@ pub const VirtualMachine = struct {
has_any_macro_remappings: bool = false,
is_from_devserver: bool = false,
has_enabled_macro_mode: bool = false,
+
+ /// The arguments used to launch the process _after_ the script name and bun and any flags applied to Bun
+ /// "bun run foo --bar"
+ /// ["--bar"]
+ /// "bun run foo baz --bar"
+ /// ["baz", "--bar"]
+ /// "bun run foo
+ /// []
+ /// "bun foo --bar"
+ /// ["--bar"]
+ /// "bun foo baz --bar"
+ /// ["baz", "--bar"]
+ /// "bun foo
+ /// []
argv: []const []const u8 = &[_][]const u8{"bun"},
+
global_api_constructors: [GlobalConstructors.len]JSC.JSValue = undefined,
origin_timer: std.time.Timer = undefined,