From 7f5351d05eea78ad35cfbcb8c5e2bbc738495a31 Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 27 Feb 2026 11:04:42 +0100 Subject: [PATCH] IPC: eagerly init unix sockets on startup --- src/util/util/Event.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/util/util/Event.ts b/src/util/util/Event.ts index c2ce1a277..b6020c61c 100644 --- a/src/util/util/Event.ts +++ b/src/util/util/Event.ts @@ -69,8 +69,8 @@ export async function emitEvent(payload: Omit) { await publishEvent(); } else if (process.env.EVENT_TRANSMISSION === "unix" && process.env.EVENT_SOCKET_PATH) { if (!unixSocketWriter) { - unixSocketWriter = new UnixSocketWriter(process.env.EVENT_SOCKET_PATH); - await unixSocketWriter.init(); + console.error("[Event] Unix socket writer not initialized, cannot emit event!"); + throw new Error("Unix socket writer not initialized"); } await unixSocketWriter.emit(payload); } else if (process.env.EVENT_TRANSMISSION === "process") { @@ -83,6 +83,13 @@ export async function emitEvent(payload: Omit) { export async function initEvent() { await RabbitMQ.init(); // does nothing if rabbitmq is not setup + if (process.env.EVENT_TRANSMISSION === "unix" && process.env.EVENT_SOCKET_PATH) { + if (!unixSocketWriter) { + unixSocketWriter = new UnixSocketWriter(process.env.EVENT_SOCKET_PATH); + await unixSocketWriter.init(); + } + } + // Set up the spacebar event listener (used for config reload, etc.) const setupSpacebarListener = async () => { console.log("[Event] Setting up spacebar event listener");