Fix circular dependency crash in worker service
**Problem:** Worker service crashed on startup with: TypeError: Cannot read properties of undefined (reading 'get') at new Wd (.../worker-service.cjs:52:131469) **Root Cause:** Circular dependency between SettingsDefaultsManager and logger: 1. SettingsDefaultsManager imports logger 2. logger imports SettingsDefaultsManager 3. logger constructor calls SettingsDefaultsManager.get() at init time 4. When CommonJS resolves the cycle, SettingsDefaultsManager is undefined **Solution:** Break the circular dependency by making logger lazy-load its configuration: - Change logger.level from initialized in constructor to lazy-loaded - Add getLevel() method that loads on first access - Update all level checks to use getLevel() This allows SettingsDefaultsManager to import logger without triggering the circular dependency, since logger no longer accesses SettingsDefaultsManager during module initialization. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -291,6 +291,7 @@ export class SessionRoutes extends BaseRouteHandler {
|
||||
? stripMemoryTagsFromJson(JSON.stringify(tool_input))
|
||||
: '{}';
|
||||
} catch (error) {
|
||||
logger.debug('SESSION', 'Failed to serialize tool_input', { sessionDbId }, error);
|
||||
cleanedToolInput = '{"error": "Failed to serialize tool_input"}';
|
||||
}
|
||||
|
||||
@@ -299,6 +300,7 @@ export class SessionRoutes extends BaseRouteHandler {
|
||||
? stripMemoryTagsFromJson(JSON.stringify(tool_response))
|
||||
: '{}';
|
||||
} catch (error) {
|
||||
logger.debug('SESSION', 'Failed to serialize tool_result', { sessionDbId }, error);
|
||||
cleanedToolResponse = '{"error": "Failed to serialize tool_response"}';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user