diff options
author | 2023-01-27 18:33:53 -0300 | |
---|---|---|
committer | 2023-01-27 13:33:53 -0800 | |
commit | c1d05cf623694262c20449a98103ee3ee02eea40 (patch) | |
tree | 457db44f10fc4c3c940b02118f81f936de266ec4 | |
parent | 724f23c19f505a4ec18f96a047493fc5851a34b2 (diff) | |
download | bun-c1d05cf623694262c20449a98103ee3ee02eea40.tar.gz bun-c1d05cf623694262c20449a98103ee3ee02eea40.tar.zst bun-c1d05cf623694262c20449a98103ee3ee02eea40.zip |
fix(Express.js) Express.js try to use function as hostname (#1914)
-rw-r--r-- | src/bun.js/api/server.zig | 4 | ||||
-rw-r--r-- | src/bun.js/http.exports.js | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index f4f4907f1..029ce6533 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -448,6 +448,7 @@ pub const ServerConfig = struct { args.base_url = URL.parse(args.base_uri); } } else { + const hostname: string = if (has_hostname and std.mem.span(args.hostname).len > 0) std.mem.span(args.hostname) else "0.0.0.0"; const protocol: string = if (args.ssl_config != null) "https" else "http"; @@ -4370,6 +4371,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { } pub fn stopListening(this: *ThisServer, abrupt: bool) void { + httplog("stopListening", .{}); var listener = this.listener orelse return; this.listener = null; this.unref(); @@ -4434,6 +4436,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { } noinline fn onListenFailed(this: *ThisServer) void { + httplog("onListenFailed", .{}); this.unref(); var zig_str: ZigString = ZigString.init(""); @@ -4709,6 +4712,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { } pub fn listen(this: *ThisServer) void { + httplog("listen", .{}); if (ssl_enabled) { BoringSSL.load(); const ssl_config = this.config.ssl_config orelse @panic("Assertion failure: ssl_config"); diff --git a/src/bun.js/http.exports.js b/src/bun.js/http.exports.js index 1655fa09d..dd3745b30 100644 --- a/src/bun.js/http.exports.js +++ b/src/bun.js/http.exports.js @@ -43,13 +43,12 @@ export class Server extends EventEmitter { const server = this; if (typeof host === "function") { onListen = host; + host = undefined; } if (typeof port === "function") { onListen = port; - } - - if (typeof port === "object") { + } else if (typeof port === "object") { host = port?.host; port = port?.port; if (typeof port?.callback === "function") onListen = port?.callback; |