Enhance error handling and logging in early-settings and worker-utils
- Added silent debugging for settings file loading failures in early-settings.ts. - Improved error logging in worker-utils.ts for health check and worker startup failures, including detailed error information and context.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { join } from 'path';
|
||||
import { homedir } from 'os';
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { silentDebug } from '../utils/silent-debug.js';
|
||||
|
||||
const SETTINGS_PATH = join(homedir(), '.claude-mem', 'settings.json');
|
||||
|
||||
@@ -23,8 +24,8 @@ export function loadEarlySetting(key: keyof EarlySettings, defaultValue: string)
|
||||
const fileValue = data.env?.[key];
|
||||
if (fileValue !== undefined) return fileValue;
|
||||
}
|
||||
} catch {
|
||||
// Fail silently - fall through to env var
|
||||
} catch (error) {
|
||||
silentDebug('Failed to load settings file', { error, settingsPath: SETTINGS_PATH, key });
|
||||
}
|
||||
|
||||
return process.env[key] || defaultValue;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { existsSync } from "fs";
|
||||
import { homedir } from "os";
|
||||
import { spawnSync } from "child_process";
|
||||
import { SettingsDefaultsManager } from "../services/worker/settings/SettingsDefaultsManager.js";
|
||||
import { logger } from "../utils/logger.js";
|
||||
|
||||
// CRITICAL: Always use marketplace directory for PM2/ecosystem
|
||||
// This ensures cross-platform compatibility and avoids cache directory confusion
|
||||
@@ -34,7 +35,11 @@ async function isWorkerHealthy(): Promise<boolean> {
|
||||
signal: AbortSignal.timeout(HEALTH_CHECK_TIMEOUT_MS)
|
||||
});
|
||||
return response.ok;
|
||||
} catch {
|
||||
} catch (error) {
|
||||
logger.debug('SYSTEM', 'Worker health check failed', {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
errorType: error?.constructor?.name
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +107,12 @@ async function startWorker(): Promise<boolean> {
|
||||
|
||||
return false;
|
||||
} catch (error) {
|
||||
// Failed to start worker
|
||||
logger.error('SYSTEM', 'Failed to start worker', {
|
||||
platform: process.platform,
|
||||
workerScript: path.join(MARKETPLACE_ROOT, 'plugin', 'scripts', 'worker-service.cjs'),
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
marketplaceRoot: MARKETPLACE_ROOT
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user