Skip to content

High performance self-hosted photo and video management solution.

fix(server): attach error handler to accepted sockets to prevent crash on connection reset (#31079)

Aashish Bhardwaje598e1089668
diff --git a/server/src/app.common.ts b/server/src/app.common.ts
index 03d834e48b..bf796efc8d 100644
--- a/server/src/app.common.ts
+++ b/server/src/app.common.ts
@@ -91,5 +91,12 @@ export async function configureExpress(
const server = await (host ? app.listen(port, host) : app.listen(port));
server.requestTimeout = 24 * 60 * 60 * 1000;
+ // make sure every socket always has an error handler
+ server.on('connection', (socket) => {
+ socket.on('error', (error) => {
+ logger.debug(`Socket error: ${error.message}`);
+ });
+ });
+
logger.log(`${IMMICH_SERVER_START} on ${await app.getUrl()} [v${serverVersion}] [${environment}] `);
}