From 0037cfe05a0125d06ad6dedb2b137f71f4728981 Mon Sep 17 00:00:00 2001 From: chamikaJ Date: Wed, 7 Oct 2026 18:32:52 +0530 Subject: [PATCH] fix: reduce optional AppSumo extension log noise --- .../src/shared/private-extensions.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/worklenz-backend/src/shared/private-extensions.ts b/worklenz-backend/src/shared/private-extensions.ts index 4297cfb29..083093859 100644 --- a/worklenz-backend/src/shared/private-extensions.ts +++ b/worklenz-backend/src/shared/private-extensions.ts @@ -113,13 +113,29 @@ const noopAppSumoMigrationService: IAppSumoMigrationService = { }), }; +let hasLoggedMissingPrivateExtensions = false; + +const isMissingPrivateExtension = (error: unknown, modulePath: string): boolean => { + if (!(error instanceof Error)) return false; + + const moduleNotFoundError = error as NodeJS.ErrnoException; + return moduleNotFoundError.code === "MODULE_NOT_FOUND" && error.message.includes(`'${modulePath}'`); +}; + function load(modulePath: string, exportName: string, fallback: T): T { try { // eslint-disable-next-line @typescript-eslint/no-var-requires const mod = require(modulePath); return (mod[exportName] as T) ?? fallback; } catch (error) { - log_error(`private-extensions: ${modulePath} not present, using no-op (${(error as Error).message})`); + if (isMissingPrivateExtension(error, modulePath)) { + if (!hasLoggedMissingPrivateExtensions) { + console.info("Optional AppSumo extensions are unavailable; AppSumo-specific features are disabled."); + hasLoggedMissingPrivateExtensions = true; + } + } else { + log_error(error); + } return fallback; } }