diff options
author | 2022-10-12 16:39:12 -0700 | |
---|---|---|
committer | 2022-10-12 16:39:12 -0700 | |
commit | 73a611a3b9a999c9fd77a650b4f6fda71bacaf19 (patch) | |
tree | 0fb75efa9c67af0d498e544b62dc448dcf7941ab | |
parent | c5333ab59750831cba8bbe4058268716993e118a (diff) | |
download | bun-73a611a3b9a999c9fd77a650b4f6fda71bacaf19.tar.gz bun-73a611a3b9a999c9fd77a650b4f6fda71bacaf19.tar.zst bun-73a611a3b9a999c9fd77a650b4f6fda71bacaf19.zip |
Stop keeping the process alive for too long
-rw-r--r-- | src/bun.js/api/bun/subprocess.zig | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig index 5681f5bae..ce64f3787 100644 --- a/src/bun.js/api/bun/subprocess.zig +++ b/src/bun.js/api/bun/subprocess.zig @@ -61,8 +61,7 @@ pub const Subprocess = struct { pub fn unref(this: *Subprocess) void { this.this_jsvalue.clear(); - this.reffer.unref(this.globalThis.bunVM()); - this.poll_ref.unref(this.globalThis.bunVM()); + this.unrefWithoutGC(this.globalThis.bunVM()); } pub fn constructor( @@ -691,7 +690,7 @@ pub const Subprocess = struct { }; } } - sink.watch(fd); + // sink.watch(fd); return Writable{ .pipe = sink }; }, .array_buffer, .blob => { @@ -1208,12 +1207,19 @@ pub const Subprocess = struct { } if (!sync) { + var vm = this.globalThis.bunVM(); + this.unrefWithoutGC(vm); this.waitpid_task = JSC.AnyTask.New(Subprocess, onExit).init(this); this.has_waitpid_task = true; - this.globalThis.bunVM().eventLoop().enqueueTask(JSC.Task.init(&this.waitpid_task)); + vm.eventLoop().enqueueTask(JSC.Task.init(&this.waitpid_task)); } } + pub fn unrefWithoutGC(this: *Subprocess, vm: *JSC.VirtualMachine) void { + this.poll_ref.unref(vm); + this.reffer.unref(vm); + } + fn onExit(this: *Subprocess) void { this.closePorts(); |