From 65e4a09b10be7cf5f4d623fb6b4be726504a9f51 Mon Sep 17 00:00:00 2001 From: cirospaciari Date: Fri, 30 Jun 2023 17:39:49 -0300 Subject: [PATCH] fix deinit on CallbackJobs --- src/bun.js/api/bun.zig | 2 ++ src/bun.js/api/bun/socket.zig | 7 +++++-- src/js/node/net.js | 4 ++++ test/js/third_party/nodemailer/nodemailer.test.ts | 6 +----- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index 2e6381c745b283..1e5a5e00418855 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -3794,6 +3794,8 @@ pub const Timer = struct { result.then(globalThis, this, CallbackJob__onResolve, CallbackJob__onReject); }, } + } else { + this.deinit(); } } }; diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index c49713dbd8c1c2..3f566ed57b2c11 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -129,7 +129,7 @@ const Handlers = struct { } pub fn markInactive(this: *Handlers, ssl: bool, ctx: *uws.SocketContext, wrapped: WrappedType) void { - Listener.log("markInactive", .{}); + Listener.log("markInactive {} {}", .{ wrapped, this.active_connections }); this.active_connections -= 1; if (this.active_connections == 0) { if (this.is_server) { @@ -1106,7 +1106,10 @@ fn NewSocket(comptime ssl: bool) type { this.handlers.markInactive(ssl, this.socket.context(), this.wrapped); this.poll_ref.unref(vm); this.has_pending_activity.store(false, .Release); + log("markInactive ok! {}", .{this.wrapped}); + return; } + log("markInactive not yet {}", .{this.wrapped}); } pub fn onOpen(this: *This, socket: Socket) void { @@ -1954,7 +1957,7 @@ fn NewSocket(comptime ssl: bool) type { this.poll_ref.unref(vm); this.has_pending_activity.store(false, .Release); } - + const array = JSC.JSValue.createEmptyArray(globalObject, 2); array.putIndex(globalObject, 0, raw_js_value); array.putIndex(globalObject, 1, tls_js_value); diff --git a/src/js/node/net.js b/src/js/node/net.js index ece867c250ad56..fce206b0cc9009 100644 --- a/src/js/node/net.js +++ b/src/js/node/net.js @@ -605,6 +605,10 @@ const Socket = (function (InternalSocket) { this.#writeChunk = chunk; } } + + prependoncelistener(){ + console.log("hey!", arguments); + } }, ); diff --git a/test/js/third_party/nodemailer/nodemailer.test.ts b/test/js/third_party/nodemailer/nodemailer.test.ts index e239179c2b0de4..6870157a31290b 100644 --- a/test/js/third_party/nodemailer/nodemailer.test.ts +++ b/test/js/third_party/nodemailer/nodemailer.test.ts @@ -1,15 +1,12 @@ import { test, expect, describe } from "bun:test"; import nodemailer from "nodemailer"; describe("nodemailer", () => { - // test hangs so we skip it until is investagated - test.skip("basic smtp", async () => { + test("basic smtp", async () => { const account = await nodemailer.createTestAccount(); const transporter = nodemailer.createTransport({ host: account.smtp.host, port: account.smtp.port, secure: account.smtp.secure, - logger: true, - debugger: true, auth: { user: account.user, // generated ethereal user pass: account.pass, // generated ethereal password @@ -25,7 +22,6 @@ describe("nodemailer", () => { html: "Hello world?", // html body }); const url = nodemailer.getTestMessageUrl(info); - expect(url).toBeString(); transporter.close(); }, 10000);