From 37d977e444ea6a5ee6f2a8a8009c973689721f00 Mon Sep 17 00:00:00 2001 From: Christian Risi <75698846+CnF-Gris@users.noreply.github.com> Date: Fri, 4 Jul 2025 10:11:57 +0000 Subject: [PATCH] Fixed a bug where the map wasn't initialized before use --- .../FileSystem/Endpoint-Manager.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/lib/server/broker-utils/FileSystem/Endpoint-Manager.ts b/src/lib/server/broker-utils/FileSystem/Endpoint-Manager.ts index 576cedd..7e80331 100644 --- a/src/lib/server/broker-utils/FileSystem/Endpoint-Manager.ts +++ b/src/lib/server/broker-utils/FileSystem/Endpoint-Manager.ts @@ -30,6 +30,8 @@ export class EndpointBrokerManagerFS { throw new Error("Broker already initialized") } + EndpointBrokerManagerFS.endpoints = new Map() + const candidateConfigurations = (await listFiles(NGINX_TRACKED, true)) const configurations: string[] = [] @@ -64,6 +66,11 @@ export class EndpointBrokerManagerFS { await file.release() const endpoint = await parseConf(fsHeader, conf) + logger.debug( + `Parsed Conf:\n${endpoint}`, + "Manager Init" + ) + const relativePath = confPath.replace(NGINX_TRACKED, "") EndpointBrokerManagerFS.endpoints.set( relativePath, @@ -291,13 +298,24 @@ export class EndpointBrokerManagerFS { const WATCHER = watch(NGINX_TRACK, OPTIONS, async (eventType, filename) => { + logger.debug( + `EVENT: ${eventType}\nFile: ${filename}`, + "Watcher " + ) + if (!filename) { return } + + const RELATIVE_PATH = filename const FULL_PATH = `${NGINX_TRACK}/${RELATIVE_PATH}` + if (!RELATIVE_PATH.endsWith(".conf")) { + return + } + // TODO: check if it's a directory, if so, skip @@ -420,6 +438,11 @@ export class EndpointBrokerManagerFS { } const endpoint = parseConf(fsHeader, conf) + logger.debug( + `Endpoint:\n${endpoint}`, + "Watcher Parsing" + ) + EndpointBrokerManagerFS.endpoints.set( RELATIVE_PATH, endpoint