From 4853f1feb8f3b4eae3dedd35e874ee38af784d50 Mon Sep 17 00:00:00 2001 From: Krystie Date: Thu, 18 Jun 2026 20:15:18 -0700 Subject: [PATCH] fix(server): unbreak workflow engine init - import fetchT, new NotificationManager, hoist servicesStateManager Three cascading bugs in server.js's workflow engine init block: 1. fetchT was referenced but never imported from ./src/utils/http 2. notification-manager was called as factory function but the module now exports a class (NotificationManager) - need 'new' 3. servicesStateManager was referenced in workflowCtx but only created later inside an async IIFE (out of scope at workflow init time) Result: every container start logged Workflow engine failed to initialize - fetchT is not defined and the workflow engine never actually wired to resourceMonitor/ updateManager event sources. The 'app' context workflow engine still ran but didn't get those connections. Fix: - Import fetchT at top of file - Use 'new' for NotificationManager instantiation - Hoist servicesStateManager creation before workflow init and remove the duplicate inside the health-checker async IIFE Verified: container restart shows [server] Workflow engine initialized [ResourceMonitor] Workflow engine configured [UpdateManager] Workflow engine configured in the log, no more errors at startup. Also bumps VERSION to current SHA (bump from c64bbe2). --- dashcaddy-api/VERSION | 2 +- dashcaddy-api/server.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dashcaddy-api/VERSION b/dashcaddy-api/VERSION index 8ee696e..3395ff3 100644 --- a/dashcaddy-api/VERSION +++ b/dashcaddy-api/VERSION @@ -1 +1 @@ -c64bbe2 +db14233 diff --git a/dashcaddy-api/server.js b/dashcaddy-api/server.js index 421b6e5..3c16518 100644 --- a/dashcaddy-api/server.js +++ b/dashcaddy-api/server.js @@ -3,6 +3,7 @@ * Minimal startup script - all logic moved to src/ */ const { createApp } = require('./src/app'); +const { fetchT } = require('./src/utils/http'); const platformPaths = require('./platform-paths'); // Unhandled error handlers @@ -66,6 +67,10 @@ process.on('uncaughtException', (error) => { const selfUpdater = require('./self-updater'); const portLockManager = require('./port-lock-manager'); + // Create servicesStateManager early — needed by workflow engine init + const StateManager = require('./state-manager'); + const servicesStateManager = new StateManager(SERVICES_FILE); + // Optional modules let dockerMaintenance, logDigest, bundledWorkflows; try { dockerMaintenance = require('./docker-maintenance'); } catch { /* optional */ } @@ -80,7 +85,7 @@ process.on('uncaughtException', (error) => { // Create a context with needed services const workflowCtx = { docker: { client: require('dockerode')() }, - notification: require('./notification-manager')({ + notification: new (require('./notification-manager'))({ NOTIFICATIONS_FILE: process.env.NOTIFICATIONS_FILE || require('./platform-paths').notificationsFile, fetchT, log, @@ -133,9 +138,7 @@ process.on('uncaughtException', (error) => { (async () => { try { const { syncHealthCheckerServices } = require('./startup-validator'); - const StateManager = require('./state-manager'); - const servicesStateManager = new StateManager(SERVICES_FILE); - + await syncHealthCheckerServices({ log, SERVICES_FILE,