fix(node:child_process): fix crash with ipc (#8319)

* make sure `onLongTimeout` doesn't happen

* add `onLongTimeout` handler
This commit is contained in:
Dylan Conway
2024-01-20 22:53:16 -08:00
committed by GitHub
parent 885f9372f4
commit fccab2f0da
3 changed files with 7 additions and 0 deletions

View File

@@ -1925,6 +1925,7 @@ pub const Subprocess = struct {
});
return .zero;
};
socket.setTimeout(0);
pipes_to_close.append(bun.default_allocator, bun.toFD(fds[1])) catch |err| return globalThis.handleError(err, "in posix_spawn");
actions.dup2(bun.toFD(fds[1]), bun.toFD(3)) catch |err| return globalThis.handleError(err, "in posix_spawn");
actions.close(bun.toFD(fds[1])) catch |err| return globalThis.handleError(err, "in posix_spawn");

View File

@@ -299,6 +299,11 @@ pub fn NewIPCHandler(comptime Context: type) type {
_: Socket,
) void {}
pub fn onLongTimeout(
_: *Context,
_: Socket,
) void {}
pub fn onConnectError(
_: *anyopaque,
_: Socket,

View File

@@ -3076,6 +3076,7 @@ pub const VirtualMachine = struct {
.ipc = undefined,
};
const socket = IPC.Socket.fromFd(context, fd, IPCInstance, instance, null) orelse @panic("Unable to start IPC");
socket.setTimeout(0);
instance.ipc = .{ .socket = socket };
const ptr = socket.ext(*IPCInstance);