fix(unified-session): resolve circular dependency with TimeMs
The import of TimeMs from Defaults/index.ts caused a circular dependency error in ESM: "ReferenceError: Cannot access 'TimeMs' before initialization" Solution: Define TimeMs constants locally in unified-session.ts instead of importing from Defaults. This avoids the ESM module initialization order issue.
This commit is contained in:
@@ -27,11 +27,22 @@ import {
|
||||
// Time Constants (Enterprise-grade)
|
||||
// ============================================
|
||||
|
||||
// Import TimeMs from Defaults (single source of truth)
|
||||
import { TimeMs } from '../Defaults/index.js'
|
||||
|
||||
// Re-export for convenience (but not as main export to avoid conflicts)
|
||||
export { TimeMs }
|
||||
/**
|
||||
* Time constants in milliseconds for unified session calculations.
|
||||
* Defined locally to avoid circular dependency issues with Defaults/index.ts
|
||||
*/
|
||||
const TimeMs = {
|
||||
/** One second in milliseconds */
|
||||
Second: 1_000,
|
||||
/** One minute in milliseconds */
|
||||
Minute: 60_000,
|
||||
/** One hour in milliseconds */
|
||||
Hour: 3_600_000,
|
||||
/** One day in milliseconds */
|
||||
Day: 86_400_000,
|
||||
/** One week in milliseconds */
|
||||
Week: 604_800_000,
|
||||
} as const
|
||||
|
||||
/**
|
||||
* Offset for session ID calculation (3 days in ms).
|
||||
|
||||
@@ -14,7 +14,15 @@ import {
|
||||
shouldEnableUnifiedSession,
|
||||
type UnifiedSessionOptions
|
||||
} from '../../Utils/unified-session.js'
|
||||
import { TimeMs } from '../../Defaults/index.js'
|
||||
|
||||
// TimeMs constants for testing (matching unified-session.ts)
|
||||
const TimeMs = {
|
||||
Second: 1_000,
|
||||
Minute: 60_000,
|
||||
Hour: 3_600_000,
|
||||
Day: 86_400_000,
|
||||
Week: 604_800_000,
|
||||
} as const
|
||||
|
||||
// Mock the prometheus metrics to avoid side effects
|
||||
jest.mock('../../Utils/prometheus-metrics.js', () => ({
|
||||
|
||||
Reference in New Issue
Block a user