summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-07-16 09:47:32 +0200
committerRory& <root@rory.gay>2026-07-16 09:47:32 +0200
commit8393a29b7dbcaed6a76992b851fa35ef59fe16ce (patch)
tree461f0e84e977bf4cf1f4f778251215d8c22180e7
parentClean up various other schemas (diff)
downloadserver-ts-8393a29b7dbcaed6a76992b851fa35ef59fe16ce.tar.xz
Clean up supposedly orphaned unix sockets
-rw-r--r--src/util/util/ipc/writer/UnixSocketWriter.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/util/util/ipc/writer/UnixSocketWriter.ts b/src/util/util/ipc/writer/UnixSocketWriter.ts

index c2465686..e9ee4d94 100644 --- a/src/util/util/ipc/writer/UnixSocketWriter.ts +++ b/src/util/util/ipc/writer/UnixSocketWriter.ts
@@ -101,16 +101,20 @@ export class UnixSocketWriter extends BaseEventWriter { }); this.clients[fullPath].on("error", (err) => { - console.error("[UnixSocketWriter] Unix socket client error on", fullPath, ":", err); // clean up after error if (this.clients[fullPath]) { delete this.clients[fullPath]; } + + if ("code" in err && err.code == "ECONNREFUSED") { + console.error("[UnixSocketWriter] Got ECONNREFUSED for socket", fullPath, " - assuming it is orphaned..."); + fs.unlinkSync(fullPath); + } else console.error("[UnixSocketWriter] Unix socket client error on", fullPath, ":", err); }); // handle clean socket closure - this.clients[fullPath].on("close", () => { - console.log("[UnixSocketWriter] Unix socket client closed:", fullPath); + this.clients[fullPath].on("close", (hadError) => { + console.log("[UnixSocketWriter] Unix socket client closed:", fullPath, "- hadError:", hadError); delete this.clients[fullPath]; this.openConnectionsMetric.set(Object.entries(this.clients).length); });