mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 05:42:43 +00:00
fix(runtime): improve IPC reliability + organization pass on that code (#6475)
* dfghj * Handle messages that did not finish * tidy * ok * a * Merge remote-tracking branch 'origin/main' into dave/ipc-fixes * test failures --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
@@ -294,13 +294,8 @@ pub export fn Bun__Process__send(
|
||||
return .zero;
|
||||
}
|
||||
var vm = globalObject.bunVM();
|
||||
if (vm.ipc) |ipc| {
|
||||
const fd = ipc.socket.fd();
|
||||
const success = IPC.serializeJSValueForSubprocess(
|
||||
globalObject,
|
||||
callFrame.argument(0),
|
||||
fd,
|
||||
);
|
||||
if (vm.ipc) |ipc_instance| {
|
||||
const success = ipc_instance.ipc.serializeAndSend(globalObject, callFrame.argument(0));
|
||||
return if (success) .undefined else .zero;
|
||||
} else {
|
||||
globalObject.throw("IPC Socket is no longer open.", .{});
|
||||
@@ -373,6 +368,14 @@ pub export fn Bun__onDidAppendPlugin(jsc_vm: *VirtualMachine, globalObject: *JSG
|
||||
jsc_vm.bundler.linker.plugin_runner = &jsc_vm.plugin_runner.?;
|
||||
}
|
||||
|
||||
// pub fn getGlobalExitCodeForPipeFailure() u8 {
|
||||
// if (VirtualMachine.is_main_thread_vm) {
|
||||
// return VirtualMachine.get().exit_handler.exit_code;
|
||||
// }
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
pub const ExitHandler = struct {
|
||||
exit_code: u8 = 0,
|
||||
|
||||
@@ -2803,9 +2806,8 @@ pub const VirtualMachine = struct {
|
||||
|
||||
pub const IPCInstance = struct {
|
||||
globalThis: ?*JSGlobalObject,
|
||||
socket: IPC.Socket,
|
||||
uws_context: *uws.SocketContext,
|
||||
ipc_buffer: bun.ByteList,
|
||||
ipc: IPC.IPCData,
|
||||
|
||||
pub fn handleIPCMessage(
|
||||
this: *IPCInstance,
|
||||
@@ -2855,13 +2857,13 @@ pub const VirtualMachine = struct {
|
||||
var instance = bun.default_allocator.create(IPCInstance) catch @panic("OOM");
|
||||
instance.* = .{
|
||||
.globalThis = this.global,
|
||||
.socket = socket,
|
||||
.uws_context = context,
|
||||
.ipc_buffer = bun.ByteList{},
|
||||
.ipc = .{ .socket = socket },
|
||||
};
|
||||
var ptr = socket.ext(*IPCInstance);
|
||||
ptr.?.* = instance;
|
||||
this.ipc = instance;
|
||||
instance.ipc.writeVersionPacket();
|
||||
}
|
||||
comptime {
|
||||
if (!JSC.is_bindgen)
|
||||
|
||||
Reference in New Issue
Block a user