From ec9e318c6fc408ce49b53df8a744f2d1b0197413 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Thu, 29 May 2025 21:06:16 -0700 Subject: [PATCH] deref --- src/bun.js/api/bun/h2_frame_parser.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bun.js/api/bun/h2_frame_parser.zig b/src/bun.js/api/bun/h2_frame_parser.zig index 99c657bf31..3926b828c2 100644 --- a/src/bun.js/api/bun/h2_frame_parser.zig +++ b/src/bun.js/api/bun/h2_frame_parser.zig @@ -4230,6 +4230,7 @@ pub const H2FrameParser = struct { this.detachNativeSocket(); if (JSTLSSocket.fromJS(socket_js)) |socket| { log("TLSSocket attached", .{}); + defer _ = this.flush(); if (socket.attachNativeCallback(.{ .h2 = this })) { this.native_socket = .{ .tls = socket }; } else { @@ -4241,6 +4242,7 @@ pub const H2FrameParser = struct { this.has_nonnative_backpressure = false; } else if (JSTCPSocket.fromJS(socket_js)) |socket| { log("TCPSocket attached", .{}); + defer _ = this.flush(); if (socket.attachNativeCallback(.{ .h2 = this })) { this.native_socket = .{ .tcp = socket }; @@ -4261,9 +4263,11 @@ pub const H2FrameParser = struct { switch (native_socket) { inline .tcp, .tls => |socket| { + socket.poll_ref.unref(this.globalThis.bunVM()); socket.detachNativeCallback(); }, inline .tcp_writeonly, .tls_writeonly => |socket| { + socket.poll_ref.unref(this.globalThis.bunVM()); socket.deref(); }, .none => {}, @@ -4337,6 +4341,7 @@ pub const H2FrameParser = struct { if (try options.get(globalObject, "native")) |socket_js| { if (JSTLSSocket.fromJS(socket_js)) |socket| { log("TLSSocket attached", .{}); + defer _ = this.flush(); if (socket.attachNativeCallback(.{ .h2 = this })) { this.native_socket = .{ .tls = socket }; } else { @@ -4346,6 +4351,7 @@ pub const H2FrameParser = struct { } } else if (JSTCPSocket.fromJS(socket_js)) |socket| { log("TCPSocket attached", .{}); + defer _ = this.flush(); if (socket.attachNativeCallback(.{ .h2 = this })) { this.native_socket = .{ .tcp = socket }; } else {