From 243cb10e2ab679623503b95b37418e56dfe01244 Mon Sep 17 00:00:00 2001 From: Maxime Poulin Date: Wed, 8 Feb 2023 22:05:22 -0500 Subject: [PATCH] Don't crash on oidentd socket race condition --- server/identification.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/identification.ts b/server/identification.ts index 12a08028..7362ef9a 100644 --- a/server/identification.ts +++ b/server/identification.ts @@ -118,7 +118,13 @@ class Identification { this.connections.forEach((connection) => { if (!connection.socket.remotePort || !connection.socket.localPort) { - throw new Error("Socket has no remote or local port"); + // Race condition: this can happen when more than one socket gets disconnected at + // once, since we `refresh()` for each one being added/removed. This results + // in there possibly be one or more disconnected sockets remaining when we get here. + // + // Simply skip this socket and not crash the server. + log.warn("oidentd: socket has no remote or local port?"); + return; } file +=