From 57f18d8bf9c7ed7b44f1aeec8bc0f05c7be4f1f1 Mon Sep 17 00:00:00 2001 From: cirospaciari Date: Thu, 17 Oct 2024 15:08:59 -0700 Subject: [PATCH] opsie --- src/bun.js/api/bun/h2_frame_parser.zig | 51 +++++++++++++------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/bun.js/api/bun/h2_frame_parser.zig b/src/bun.js/api/bun/h2_frame_parser.zig index 1600c06758800..10d121eaa42e7 100644 --- a/src/bun.js/api/bun/h2_frame_parser.zig +++ b/src/bun.js/api/bun/h2_frame_parser.zig @@ -3757,31 +3757,7 @@ pub const H2FrameParser = struct { globalObject.throwInvalidArguments("expected options as argument", .{}); return null; } - const socket_js = args_list.ptr[0]; - - if (!socket_js.isEmptyOrUndefinedOrNull()) { - // check if socket is provided, and if it is a valid native socket - if (JSTLSSocket.fromJS(socket_js)) |socket| { - log("TLSSocket attached", .{}); - if (socket.attachNativeCallback(.{ .h2 = this })) { - this.native_socket = .{ .tls = socket }; - } else { - socket.ref(); - - this.native_socket = .{ .tls_writeonly = socket }; - } - } else if (JSTCPSocket.fromJS(socket_js)) |socket| { - log("TCPSocket attached", .{}); - if (socket.attachNativeCallback(.{ .h2 = this })) { - this.native_socket = .{ .tcp = socket }; - } else { - socket.ref(); - - this.native_socket = .{ .tcp_writeonly = socket }; - } - } - } - + var exception: JSC.C.JSValueRef = null; const context_obj = options.get(globalObject, "context") orelse { @@ -3835,6 +3811,31 @@ pub const H2FrameParser = struct { }); } }; + const socket_js = args_list.ptr[1]; + + if (!socket_js.isEmptyOrUndefinedOrNull()) { + // check if socket is provided, and if it is a valid native socket + if (JSTLSSocket.fromJS(socket_js)) |socket| { + log("TLSSocket attached", .{}); + if (socket.attachNativeCallback(.{ .h2 = this })) { + this.native_socket = .{ .tls = socket }; + } else { + socket.ref(); + + this.native_socket = .{ .tls_writeonly = socket }; + } + } else if (JSTCPSocket.fromJS(socket_js)) |socket| { + log("TCPSocket attached", .{}); + if (socket.attachNativeCallback(.{ .h2 = this })) { + this.native_socket = .{ .tcp = socket }; + } else { + socket.ref(); + + this.native_socket = .{ .tcp_writeonly = socket }; + } + } + } + if (options.get(globalObject, "settings")) |settings_js| { if (!settings_js.isEmptyOrUndefinedOrNull()) {