aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/api')
-rw-r--r--src/bun.js/api/bun/socket.zig3
-rw-r--r--src/bun.js/api/server.zig11
2 files changed, 13 insertions, 1 deletions
diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig
index 78829f428..fa4411cc0 100644
--- a/src/bun.js/api/bun/socket.zig
+++ b/src/bun.js/api/bun/socket.zig
@@ -409,6 +409,7 @@ pub const Listener = struct {
ctx_opts.ssl_prefer_low_memory_usage = @boolToInt(ssl_config.low_memory_mode);
}
+ globalObject.bunVM().eventLoop().ensureWaker();
socket.socket_context = uws.us_create_socket_context(@boolToInt(ssl_enabled), uws.Loop.get().?, @sizeOf(usize), ctx_opts);
if (ssl) |ssl_config| {
@@ -661,6 +662,8 @@ pub const Listener = struct {
ctx_opts.ssl_prefer_low_memory_usage = @boolToInt(ssl_config.low_memory_mode);
}
+ globalObject.bunVM().eventLoop().ensureWaker();
+
var socket_context = uws.us_create_socket_context(@boolToInt(ssl_enabled), uws.Loop.get().?, @sizeOf(usize), ctx_opts).?;
var connection: Listener.UnixOrHost = if (port) |port_| .{
.host = .{ .host = (hostname_or_unix.cloneIfNeeded(bun.default_allocator) catch unreachable).slice(), .port = port_ },
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig
index fb991481f..e2892f88f 100644
--- a/src/bun.js/api/server.zig
+++ b/src/bun.js/api/server.zig
@@ -4169,6 +4169,8 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
}
pub fn onRequestComplete(this: *ThisServer) void {
+ this.vm.eventLoop().processGCTimer();
+
this.pending_requests -= 1;
this.deinitIfWeCan();
}
@@ -4567,7 +4569,14 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
this.config.hostname;
this.ref();
- this.vm.autoGarbageCollect();
+
+ // Starting up an HTTP server is a good time to GC
+ if (this.vm.aggressive_garbage_collection == .aggressive) {
+ this.vm.autoGarbageCollect();
+ } else {
+ this.vm.eventLoop().performGC();
+ }
+
this.app.listenWithConfig(*ThisServer, this, onListen, .{
.port = this.config.port,
.host = host,