From f1a52633a358da572c9e62c27a02a71e594507ee Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Tue, 9 Sep 2025 16:56:59 -0700 Subject: [PATCH] opsie --- src/sql/mysql/MySQLConnection.zig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/sql/mysql/MySQLConnection.zig b/src/sql/mysql/MySQLConnection.zig index 4ad2c8ce38..61bb5e78bb 100644 --- a/src/sql/mysql/MySQLConnection.zig +++ b/src/sql/mysql/MySQLConnection.zig @@ -421,11 +421,18 @@ pub fn fail(this: *MySQLConnection, message: []const u8, err: AnyMySQLError.Erro this.failWithJSValue(instance); } -pub fn onClose(this: *MySQLConnection) void { +pub fn onEnd(this: *MySQLConnection) void { + // no more socket defer this.deref(); this.fail("Connection closed", error.ConnectionClosed); } +pub fn onClose(this: *MySQLConnection) void { + // no more socket + defer this.deref(); + this.onEnd(); +} + fn refAndClose(this: *@This(), js_reason: ?jsc.JSValue) void { // refAndClose is always called when we wanna to disconnect or when we are closed @@ -749,7 +756,7 @@ fn SocketHandler(comptime ssl: bool) type { pub fn onEnd(this: *MySQLConnection, socket: SocketType) void { _ = socket; - this.onClose(); + this.onEnd(); } pub fn onConnectError(this: *MySQLConnection, socket: SocketType, _: i32) void {