diff options
Diffstat (limited to '')
-rw-r--r-- | src/bun.js/api/server.zig | 14 | ||||
-rw-r--r-- | test/bun.js/process-args.test.js | 10 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index f9ca6e881..a8216c689 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -3804,7 +3804,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { listen_callback: JSC.AnyTask = undefined, allocator: std.mem.Allocator, poll_ref: JSC.PollRef = .{}, - + deinit_scheduled: bool = false, temporary_url_buffer: std.ArrayListUnmanaged(u8) = .{}, pub const Class = JSC.NewClass( @@ -4291,7 +4291,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { ws.handler.app = null; } this.unref(); - this.deinit(); + this.scheduleDeinit(); } } @@ -4307,6 +4307,16 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { this.deinitIfWeCan(); } + pub fn scheduleDeinit(this: *ThisServer) void { + if (this.deinit_scheduled) + return; + this.deinit_scheduled = true; + httplog("scheduleDeinit", .{}); + var task = bun.default_allocator.create(JSC.AnyTask) catch unreachable; + task.* = JSC.AnyTask.New(ThisServer, deinit).init(this); + this.vm.enqueueTask(JSC.Task.init(task)); + } + pub fn deinit(this: *ThisServer) void { httplog("deinit", .{}); this.app.destroy(); diff --git a/test/bun.js/process-args.test.js b/test/bun.js/process-args.test.js index 512b6b92c..3b5749239 100644 --- a/test/bun.js/process-args.test.js +++ b/test/bun.js/process-args.test.js @@ -4,34 +4,32 @@ import { test, expect } from "bun:test"; test("args exclude run", async () => { const arg0 = process.argv[0]; const arg1 = import.meta.dir + "/print-process-args.js"; - const exe = process.versions.bun.includes("debug") ? "bun-debug" : "bun"; - const { stdout: s1 } = spawn([exe, "print-process-args.js"], { cwd: import.meta.dir, + env: { BUN_DEBUG_QUIET_LOGS: "1" }, }); const t1 = JSON.parse(await new Response(s1).text()); expect(t1[0]).toBe(arg0); expect(t1[1]).toBe(arg1); - const { stdout: s2 } = spawn([exe, "print-process-args.js", "arg1"], { cwd: import.meta.dir, + env: { BUN_DEBUG_QUIET_LOGS: "1" }, }); const t2 = JSON.parse(await new Response(s2).text()); expect(t2[0]).toBe(arg0); expect(t2[1]).toBe(arg1); expect(t2[2]).toBe("arg1"); - const { stdout: s3 } = spawn([exe, "run", "print-process-args.js"], { cwd: import.meta.dir, + env: { BUN_DEBUG_QUIET_LOGS: "1" }, }); const t3 = JSON.parse(await new Response(s3).text()); expect(t3[0]).toBe(arg0); expect(t3[1]).toBe(arg1); - const { stdout: s4 } = spawn( [exe, "run", "print-process-args.js", "arg1", "arg2"], - { cwd: import.meta.dir }, + { cwd: import.meta.dir, env: { BUN_DEBUG_QUIET_LOGS: "1" } }, ); const t4 = JSON.parse(await new Response(s4).text()); expect(t4[0]).toBe(arg0); |